forked from TrueCloudLab/restic
fuse: Remove struct SnapshotWithId
This commit is contained in:
parent
052a6a0acc
commit
56f610e548
2 changed files with 9 additions and 14 deletions
|
@ -69,11 +69,11 @@ func replaceSpecialNodes(ctx context.Context, repo restic.Repository, node *rest
|
||||||
return tree.Nodes, nil
|
return tree.Nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDirFromSnapshot(ctx context.Context, repo restic.Repository, snapshot SnapshotWithId, ownerIsRoot bool, blobsize *BlobSizeCache) (*dir, error) {
|
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())
|
debug.Log("new dir for snapshot %v (%v)", snapshot.ID().Str(), snapshot.Tree.Str())
|
||||||
tree, err := repo.LoadTree(ctx, *snapshot.Tree)
|
tree, err := repo.LoadTree(ctx, *snapshot.Tree)
|
||||||
if err != nil {
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
items := make(map[string]*restic.Node)
|
items := make(map[string]*restic.Node)
|
||||||
|
@ -100,7 +100,7 @@ func newDirFromSnapshot(ctx context.Context, repo restic.Repository, snapshot Sn
|
||||||
Mode: os.ModeDir | 0555,
|
Mode: os.ModeDir | 0555,
|
||||||
},
|
},
|
||||||
items: items,
|
items: items,
|
||||||
inode: inodeFromBackendID(snapshot.ID),
|
inode: inodeFromBackendID(*snapshot.ID()),
|
||||||
ownerIsRoot: ownerIsRoot,
|
ownerIsRoot: ownerIsRoot,
|
||||||
blobsize: blobsize,
|
blobsize: blobsize,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -47,11 +47,6 @@ func (c *BlobSizeCache) Lookup(id restic.ID) (size uint, found bool) {
|
||||||
return size, found
|
return size, found
|
||||||
}
|
}
|
||||||
|
|
||||||
type SnapshotWithId struct {
|
|
||||||
*restic.Snapshot
|
|
||||||
restic.ID
|
|
||||||
}
|
|
||||||
|
|
||||||
// These lines statically ensure that a *SnapshotsDir implement the given
|
// These lines statically ensure that a *SnapshotsDir implement the given
|
||||||
// interfaces; a misplaced refactoring of the implementation that breaks
|
// interfaces; a misplaced refactoring of the implementation that breaks
|
||||||
// the interface will be catched by the compiler
|
// the interface will be catched by the compiler
|
||||||
|
@ -69,7 +64,7 @@ type SnapshotsDir struct {
|
||||||
|
|
||||||
// knownSnapshots maps snapshot timestamp to the snapshot
|
// knownSnapshots maps snapshot timestamp to the snapshot
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
knownSnapshots map[string]SnapshotWithId
|
knownSnapshots map[string]*restic.Snapshot
|
||||||
processed restic.IDSet
|
processed restic.IDSet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +77,7 @@ func NewSnapshotsDir(repo restic.Repository, ownerIsRoot bool, paths []string, t
|
||||||
paths: paths,
|
paths: paths,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
host: host,
|
host: host,
|
||||||
knownSnapshots: make(map[string]SnapshotWithId),
|
knownSnapshots: make(map[string]*restic.Snapshot),
|
||||||
processed: restic.NewIDSet(),
|
processed: restic.NewIDSet(),
|
||||||
blobsize: NewBlobSizeCache(repo.Index().(*repository.MasterIndex)),
|
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)
|
debug.Log(" add %v as dir %v", id.Str(), timestamp)
|
||||||
sn.knownSnapshots[timestamp] = SnapshotWithId{snapshot, id}
|
sn.knownSnapshots[timestamp] = snapshot
|
||||||
sn.processed.Insert(id)
|
sn.processed.Insert(id)
|
||||||
}
|
}
|
||||||
return nil
|
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()
|
sn.Lock()
|
||||||
snapshot, ok = sn.knownSnapshots[name]
|
snapshot, ok = sn.knownSnapshots[name]
|
||||||
sn.Unlock()
|
sn.Unlock()
|
||||||
|
@ -161,7 +156,7 @@ func (sn *SnapshotsDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||||
ret := make([]fuse.Dirent, 0)
|
ret := make([]fuse.Dirent, 0)
|
||||||
for timestamp, snapshot := range sn.knownSnapshots {
|
for timestamp, snapshot := range sn.knownSnapshots {
|
||||||
ret = append(ret, fuse.Dirent{
|
ret = append(ret, fuse.Dirent{
|
||||||
Inode: inodeFromBackendID(snapshot.ID),
|
Inode: inodeFromBackendID(*snapshot.ID()),
|
||||||
Type: fuse.DT_Dir,
|
Type: fuse.DT_Dir,
|
||||||
Name: timestamp,
|
Name: timestamp,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue