Merge pull request #1507 from restic/fix-fuse-list-timeout

fuse: Only reload list of snapshots once per minute
This commit is contained in:
Alexander Neumann 2017-12-28 14:06:59 +01:00
commit c686dd0448
4 changed files with 16 additions and 1 deletions

View File

@ -0,0 +1,3 @@
Enhancement: Only reload snapshots once per minute for fuse mount
https://github.com/restic/restic/pull/1507

View File

@ -3,6 +3,7 @@
#
# The resulting changelog generated by `calens` will list all versions in
# exactly this order.
0.8.2
0.8.1 2017-12-27
0.8.0 2017-11-26
0.7.3 2017-09-20

View File

@ -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
}

View File

@ -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.