mirror of
https://github.com/octoleo/restic.git
synced 2024-11-27 07:16:40 +00:00
fuse: handle duplicate timestamps for snapshots
This closes #606, which fails because several snapshots are created with exactly the same timestamp, and the code checks that for each snapshot there is a dir in the fuse mount. This fails for colliding timestamps, so we now add a suffix "-1", "-2" etc for each duplicate timestamp.
This commit is contained in:
parent
6485a6cdc0
commit
a0f3e94655
@ -4,6 +4,7 @@
|
||||
package fuse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
@ -65,11 +66,24 @@ func (sn *SnapshotsDir) updateCache(ctx context.Context) error {
|
||||
defer sn.Unlock()
|
||||
|
||||
for id := range sn.repo.List(restic.SnapshotFile, ctx.Done()) {
|
||||
debug.Log("SnapshotsDir.List", "found snapshot id %v", id.Str())
|
||||
snapshot, err := restic.LoadSnapshot(sn.repo, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sn.knownSnapshots[snapshot.Time.Format(time.RFC3339)] = SnapshotWithId{snapshot, id}
|
||||
|
||||
timestamp := snapshot.Time.Format(time.RFC3339)
|
||||
|
||||
for i := 1; ; i++ {
|
||||
if _, ok := sn.knownSnapshots[timestamp]; !ok {
|
||||
break
|
||||
}
|
||||
|
||||
timestamp = fmt.Sprintf("%s-%d", snapshot.Time.Format(time.RFC3339), i)
|
||||
}
|
||||
|
||||
debug.Log("SnapshotsDir.List", " add %v as dir %v", id.Str(), timestamp)
|
||||
sn.knownSnapshots[timestamp] = SnapshotWithId{snapshot, id}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user