diff --git a/internal/fuse/root.go b/internal/fuse/root.go index d6ca78b1b..c6abc3bf2 100644 --- a/internal/fuse/root.go +++ b/internal/fuse/root.go @@ -4,6 +4,8 @@ package fuse import ( + "time" + "github.com/restic/restic/internal/debug" "github.com/restic/restic/internal/restic" @@ -27,7 +29,9 @@ type Root struct { inode uint64 snapshots restic.Snapshots blobSizeCache *BlobSizeCache - snCount int + + snCount int + lastCheck time.Time *MetaDir } diff --git a/internal/fuse/snapshots_dir.go b/internal/fuse/snapshots_dir.go index 47c691fea..19c785224 100644 --- a/internal/fuse/snapshots_dir.go +++ b/internal/fuse/snapshots_dir.go @@ -221,14 +221,21 @@ func isElem(e string, list []string) bool { return false } +const minSnapshotsReloadTime = 60 * time.Second + // update snapshots if repository has changed func updateSnapshots(ctx context.Context, root *Root) { + if time.Since(root.lastCheck) < minSnapshotsReloadTime { + return + } + 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() } // read snapshot timestamps from the current repository-state.