mirror of
https://github.com/restic/restic.git
synced 2025-08-12 11:47:43 +00:00
Fix calls to repo/backend.List() everywhere
This commit is contained in:
@@ -35,11 +35,17 @@ func testRead(t testing.TB, f *file, offset, length int, data []byte) {
|
||||
}
|
||||
|
||||
func firstSnapshotID(t testing.TB, repo restic.Repository) (first restic.ID) {
|
||||
for id := range repo.List(context.TODO(), restic.SnapshotFile) {
|
||||
err := repo.List(context.TODO(), restic.SnapshotFile, func(id restic.ID, size int64) error {
|
||||
if first.IsNull() {
|
||||
first = id
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
return first
|
||||
}
|
||||
|
||||
|
@@ -227,18 +227,24 @@ func isElem(e string, list []string) bool {
|
||||
const minSnapshotsReloadTime = 60 * time.Second
|
||||
|
||||
// update snapshots if repository has changed
|
||||
func updateSnapshots(ctx context.Context, root *Root) {
|
||||
func updateSnapshots(ctx context.Context, root *Root) error {
|
||||
if time.Since(root.lastCheck) < minSnapshotsReloadTime {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
snapshots, err := restic.FindFilteredSnapshots(ctx, root.repo, root.cfg.Host, root.cfg.Tags, root.cfg.Paths)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
snapshots := restic.FindFilteredSnapshots(ctx, root.repo, root.cfg.Host, root.cfg.Tags, root.cfg.Paths)
|
||||
if root.snCount != len(snapshots) {
|
||||
root.snCount = len(snapshots)
|
||||
root.repo.LoadIndex(ctx)
|
||||
root.snapshots = snapshots
|
||||
}
|
||||
root.lastCheck = time.Now()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// read snapshot timestamps from the current repository-state.
|
||||
|
Reference in New Issue
Block a user