mirror of
https://github.com/restic/restic.git
synced 2026-11-22 13:24:24 +00:00
data: use data.TreeWriter to serialize&write data.Tree
Always serialize trees via TreeJSONBuilder. Add a wrapper called TreeWriter which combines serialization and saving the tree blob in the repository. In the future, TreeJSONBuilder will have to upload tree chunks while the tree is still serialized. This will a wrapper like TreeWriter, so add it right now already. The archiver.treeSaver still directly uses the TreeJSONBuilder as it requires special handling.
This commit is contained in:
1 parent
f84d398989
commit
278e457e1f
3 files changed
+51
-40
No files matched your search
@@ -121,7 +121,7 @@ func (t *TreeRewriter) RewriteTree(ctx context.Context, loader restic.BlobLoader
|
||||
|
||||
debug.Log("filterTree: %s, nodeId: %s\n", nodepath, nodeID.Str())
|
||||
|
||||
tb := data.NewTreeJSONBuilder()
|
||||
tb := data.NewTreeWriter(saver)
|
||||
for _, node := range curTree.Nodes {
|
||||
if ctx.Err() != nil {
|
||||
return restic.ID{}, ctx.Err()
|
||||
@@ -156,13 +156,11 @@ func (t *TreeRewriter) RewriteTree(ctx context.Context, loader restic.BlobLoader
|
||||
}
|
||||
}
|
||||
|
||||
tree, err := tb.Finalize()
|
||||
newTreeID, err := tb.Finalize(ctx)
|
||||
if err != nil {
|
||||
return restic.ID{}, err
|
||||
}
|
||||
|
||||
// Save new tree
|
||||
newTreeID, _, _, err := saver.SaveBlob(ctx, restic.TreeBlob, tree, restic.ID{}, false)
|
||||
if t.replaces != nil {
|
||||
t.replaces[nodeID] = newTreeID
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user