提交 234ad181 作者: Steven Allen

make the tar writer handle sharded ipfs directories

makes ipfs get work on sharded directories

fixes #4871

License: MIT
Signed-off-by: 's avatarSteven Allen <steven@stebalien.com>
上级 3cbf97be
......@@ -39,23 +39,25 @@ func NewWriter(ctx context.Context, dag ipld.DAGService, archive bool, compressi
}
func (w *Writer) writeDir(nd *mdag.ProtoNode, fpath string) error {
dir, err := uio.NewDirectoryFromNode(w.Dag, nd)
if err != nil {
return err
}
if err := writeDirHeader(w.TarW, fpath); err != nil {
return err
}
for i, ng := range ipld.GetDAG(w.ctx, w.Dag, nd) {
child, err := ng.Get(w.ctx)
return dir.ForEachLink(w.ctx, func(l *ipld.Link) error {
child, err := w.Dag.Get(w.ctx, l.Cid)
if err != nil {
return err
}
npath := path.Join(fpath, nd.Links()[i].Name)
npath := path.Join(fpath, l.Name)
if err := w.WriteNode(child, npath); err != nil {
return err
}
}
return nil
return nil
})
}
func (w *Writer) writeFile(nd *mdag.ProtoNode, pb *upb.Data, fpath string) error {
......@@ -83,7 +85,7 @@ func (w *Writer) WriteNode(nd ipld.Node, fpath string) error {
switch pb.GetType() {
case upb.Data_Metadata:
fallthrough
case upb.Data_Directory:
case upb.Data_Directory, upb.Data_HAMTShard:
return w.writeDir(nd, fpath)
case upb.Data_Raw:
fallthrough
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论