mirror of
https://github.com/restic/restic.git
synced 2026-08-16 10:33:17 +00:00
backup/diff/dump/restore/stats: List snapshots before index
During a backup the index is written before the corresponding snapshots. To ensure that a concurrent/later restic run can read a snapshot's data, restic thus must first load the snapshots and only afterwards the index. Otherwise it is not possible to ensure that the loaded index is recent enough to cover all of the snapshot's data.
This commit is contained in:
@@ -334,10 +334,6 @@ func runDiff(opts DiffOptions, gopts GlobalOptions, args []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = repo.LoadIndex(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !gopts.NoLock {
|
||||
lock, err := lockRepo(ctx, repo)
|
||||
defer unlockRepo(lock)
|
||||
@@ -360,6 +356,10 @@ func runDiff(opts DiffOptions, gopts GlobalOptions, args []string) error {
|
||||
Verbosef("comparing snapshot %v to %v:\n\n", sn1.ID().Str(), sn2.ID().Str())
|
||||
}
|
||||
|
||||
if err = repo.LoadIndex(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if sn1.Tree == nil {
|
||||
return errors.Errorf("snapshot %v has nil tree", sn1.ID().Str())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user