mirror of
https://github.com/restic/restic.git
synced 2025-03-13 19:22:39 +00:00
rewrite: Don't walk snapshot content if only metadata is modified
This commit is contained in:
parent
893d0d6325
commit
2730d05fce
@ -123,6 +123,9 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var filter rewriteFilterFunc
|
||||||
|
|
||||||
|
if len(rejectByNameFuncs) > 0 {
|
||||||
selectByName := func(nodepath string) bool {
|
selectByName := func(nodepath string) bool {
|
||||||
for _, reject := range rejectByNameFuncs {
|
for _, reject := range rejectByNameFuncs {
|
||||||
if reject(nodepath) {
|
if reject(nodepath) {
|
||||||
@ -143,10 +146,17 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti
|
|||||||
DisableNodeCache: true,
|
DisableNodeCache: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
return filterAndReplaceSnapshot(ctx, repo, sn,
|
filter = func(ctx context.Context, sn *restic.Snapshot) (restic.ID, error) {
|
||||||
func(ctx context.Context, sn *restic.Snapshot) (restic.ID, error) {
|
|
||||||
return rewriter.RewriteTree(ctx, repo, "/", *sn.Tree)
|
return rewriter.RewriteTree(ctx, repo, "/", *sn.Tree)
|
||||||
}, opts.DryRun, opts.Forget, metadata, "rewrite")
|
}
|
||||||
|
} else {
|
||||||
|
filter = func(ctx context.Context, sn *restic.Snapshot) (restic.ID, error) {
|
||||||
|
return *sn.Tree, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filterAndReplaceSnapshot(ctx, repo, sn,
|
||||||
|
filter, opts.DryRun, opts.Forget, metadata, "rewrite")
|
||||||
}
|
}
|
||||||
|
|
||||||
func filterAndReplaceSnapshot(ctx context.Context, repo restic.Repository, sn *restic.Snapshot,
|
func filterAndReplaceSnapshot(ctx context.Context, repo restic.Repository, sn *restic.Snapshot,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user