mirror of
https://github.com/octoleo/restic.git
synced 2024-12-01 09:13:56 +00:00
Merge pull request #1507 from restic/fix-fuse-list-timeout
fuse: Only reload list of snapshots once per minute
This commit is contained in:
commit
c686dd0448
3
changelog/0.8.2/pull-1507
Normal file
3
changelog/0.8.2/pull-1507
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Enhancement: Only reload snapshots once per minute for fuse mount
|
||||||
|
|
||||||
|
https://github.com/restic/restic/pull/1507
|
@ -3,6 +3,7 @@
|
|||||||
#
|
#
|
||||||
# The resulting changelog generated by `calens` will list all versions in
|
# The resulting changelog generated by `calens` will list all versions in
|
||||||
# exactly this order.
|
# exactly this order.
|
||||||
|
0.8.2
|
||||||
0.8.1 2017-12-27
|
0.8.1 2017-12-27
|
||||||
0.8.0 2017-11-26
|
0.8.0 2017-11-26
|
||||||
0.7.3 2017-09-20
|
0.7.3 2017-09-20
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user