2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-11 15:51:02 +00:00

rewrite: Always set the Original field in a rewritten snapshot

The Original field is meant to remember the original snapshot id if e.g.
changing its tags. It was only set by the `rewrite` command if it was
not set previously. However, a rewritten snapshot is potentially rather
different from the original snapshot. Thus just always set the Original
field. This also makes it easier to later on detect and potentially
remove the original snapshots.
This commit is contained in:
Michael Eischer 2022-12-10 12:40:41 +01:00
parent 049a105ba5
commit 38b2e9b42c
2 changed files with 3 additions and 4 deletions

View File

@ -5,3 +5,4 @@ unwanted files.
https://github.com/restic/restic/issues/14 https://github.com/restic/restic/issues/14
https://github.com/restic/restic/pull/2731 https://github.com/restic/restic/pull/2731
https://github.com/restic/restic/pull/4079

View File

@ -123,10 +123,8 @@ func rewriteSnapshot(ctx context.Context, repo *repository.Repository, sn *resti
return true, nil return true, nil
} }
// Retain the original snapshot id over all tag changes. // Always set the original snapshot id as this essentially a new snapshot.
if sn.Original == nil {
sn.Original = sn.ID() sn.Original = sn.ID()
}
*sn.Tree = filteredTree *sn.Tree = filteredTree
if !opts.Forget { if !opts.Forget {