mirror of
https://github.com/ipfs/kubo.git
synced 2025-10-25 02:16:56 +08:00
give ipfs get symlink support
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
@ -79,6 +79,8 @@ func (w *Writer) WriteNode(nd *mdag.Node, fpath string) error {
|
||||
fallthrough
|
||||
case upb.Data_File:
|
||||
return w.writeFile(nd, pb, fpath)
|
||||
case upb.Data_Symlink:
|
||||
return writeSymlinkHeader(w.TarW, string(pb.GetData()), fpath)
|
||||
default:
|
||||
return ft.ErrUnrecognizedType
|
||||
}
|
||||
@ -108,3 +110,12 @@ func writeFileHeader(w *tar.Writer, fpath string, size uint64) error {
|
||||
// TODO: set mode, dates, etc. when added to unixFS
|
||||
})
|
||||
}
|
||||
|
||||
func writeSymlinkHeader(w *tar.Writer, target, fpath string) error {
|
||||
return w.WriteHeader(&tar.Header{
|
||||
Name: fpath,
|
||||
Linkname: target,
|
||||
Mode: 0777,
|
||||
Typeflag: tar.TypeSymlink,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user