diff --git a/src/restic/fuse/dir.go b/src/restic/fuse/dir.go index f7920f6ca..78049fddc 100644 --- a/src/restic/fuse/dir.go +++ b/src/restic/fuse/dir.go @@ -69,11 +69,11 @@ func replaceSpecialNodes(ctx context.Context, repo restic.Repository, node *rest return tree.Nodes, nil } -func newDirFromSnapshot(ctx context.Context, repo restic.Repository, snapshot SnapshotWithId, ownerIsRoot bool, blobsize *BlobSizeCache) (*dir, error) { - debug.Log("new dir for snapshot %v (%v)", snapshot.ID.Str(), snapshot.Tree.Str()) +func newDirFromSnapshot(ctx context.Context, repo restic.Repository, snapshot *restic.Snapshot, ownerIsRoot bool, blobsize *BlobSizeCache) (*dir, error) { + debug.Log("new dir for snapshot %v (%v)", snapshot.ID().Str(), snapshot.Tree.Str()) tree, err := repo.LoadTree(ctx, *snapshot.Tree) if err != nil { - debug.Log(" loadTree(%v) failed: %v", snapshot.ID.Str(), err) + debug.Log(" loadTree(%v) failed: %v", snapshot.ID().Str(), err) return nil, err } items := make(map[string]*restic.Node) @@ -100,7 +100,7 @@ func newDirFromSnapshot(ctx context.Context, repo restic.Repository, snapshot Sn Mode: os.ModeDir | 0555, }, items: items, - inode: inodeFromBackendID(snapshot.ID), + inode: inodeFromBackendID(*snapshot.ID()), ownerIsRoot: ownerIsRoot, blobsize: blobsize, }, nil diff --git a/src/restic/fuse/snapshot.go b/src/restic/fuse/snapshot.go index 06bf41cbd..7701af318 100644 --- a/src/restic/fuse/snapshot.go +++ b/src/restic/fuse/snapshot.go @@ -47,11 +47,6 @@ func (c *BlobSizeCache) Lookup(id restic.ID) (size uint, found bool) { return size, found } -type SnapshotWithId struct { - *restic.Snapshot - restic.ID -} - // These lines statically ensure that a *SnapshotsDir implement the given // interfaces; a misplaced refactoring of the implementation that breaks // the interface will be catched by the compiler @@ -69,7 +64,7 @@ type SnapshotsDir struct { // knownSnapshots maps snapshot timestamp to the snapshot sync.Mutex - knownSnapshots map[string]SnapshotWithId + knownSnapshots map[string]*restic.Snapshot processed restic.IDSet } @@ -82,7 +77,7 @@ func NewSnapshotsDir(repo restic.Repository, ownerIsRoot bool, paths []string, t paths: paths, tags: tags, host: host, - knownSnapshots: make(map[string]SnapshotWithId), + knownSnapshots: make(map[string]*restic.Snapshot), processed: restic.NewIDSet(), blobsize: NewBlobSizeCache(repo.Index().(*repository.MasterIndex)), } @@ -134,13 +129,13 @@ func (sn *SnapshotsDir) updateCache(ctx context.Context) error { } debug.Log(" add %v as dir %v", id.Str(), timestamp) - sn.knownSnapshots[timestamp] = SnapshotWithId{snapshot, id} + sn.knownSnapshots[timestamp] = snapshot sn.processed.Insert(id) } return nil } -func (sn *SnapshotsDir) get(name string) (snapshot SnapshotWithId, ok bool) { +func (sn *SnapshotsDir) get(name string) (snapshot *restic.Snapshot, ok bool) { sn.Lock() snapshot, ok = sn.knownSnapshots[name] sn.Unlock() @@ -161,7 +156,7 @@ func (sn *SnapshotsDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { ret := make([]fuse.Dirent, 0) for timestamp, snapshot := range sn.knownSnapshots { ret = append(ret, fuse.Dirent{ - Inode: inodeFromBackendID(snapshot.ID), + Inode: inodeFromBackendID(*snapshot.ID()), Type: fuse.DT_Dir, Name: timestamp, })