1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-01-03 13:45:20 +00:00

fuse: Only reload list of snapshots once per minute

This commit is contained in:
Alexander Neumann 2017-12-28 13:18:27 +01:00
parent 8d8456590c
commit 3f7d85360a
2 changed files with 12 additions and 1 deletions

View file

@ -4,6 +4,8 @@
package fuse package fuse
import ( import (
"time"
"github.com/restic/restic/internal/debug" "github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/restic" "github.com/restic/restic/internal/restic"
@ -27,7 +29,9 @@ type Root struct {
inode uint64 inode uint64
snapshots restic.Snapshots snapshots restic.Snapshots
blobSizeCache *BlobSizeCache blobSizeCache *BlobSizeCache
snCount int snCount int
lastCheck time.Time
*MetaDir *MetaDir
} }

View file

@ -221,14 +221,21 @@ func isElem(e string, list []string) bool {
return false return false
} }
const minSnapshotsReloadTime = 60 * time.Second
// update snapshots if repository has changed // update snapshots if repository has changed
func updateSnapshots(ctx context.Context, root *Root) { 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) snapshots := restic.FindFilteredSnapshots(ctx, root.repo, root.cfg.Host, root.cfg.Tags, root.cfg.Paths)
if root.snCount != len(snapshots) { if root.snCount != len(snapshots) {
root.snCount = len(snapshots) root.snCount = len(snapshots)
root.repo.LoadIndex(ctx) root.repo.LoadIndex(ctx)
root.snapshots = snapshots root.snapshots = snapshots
} }
root.lastCheck = time.Now()
} }
// read snapshot timestamps from the current repository-state. // read snapshot timestamps from the current repository-state.