forked from TrueCloudLab/restic
Merge pull request #1299 from mungomat/fuse_addSnapshotIDs
fuse: Add a snapshot IDs directory (#1102)
This commit is contained in:
commit
6a62254048
2 changed files with 21 additions and 0 deletions
|
@ -56,6 +56,7 @@ func NewRoot(ctx context.Context, repo restic.Repository, cfg Config) (*Root, er
|
|||
"snapshots": NewSnapshotsDir(root, fs.GenerateDynamicInode(root.inode, "snapshots"), snapshots),
|
||||
"tags": NewTagsDir(root, fs.GenerateDynamicInode(root.inode, "tags"), snapshots),
|
||||
"hosts": NewHostsDir(root, fs.GenerateDynamicInode(root.inode, "hosts"), snapshots),
|
||||
"ids": NewSnapshotsIDSDir(root, fs.GenerateDynamicInode(root.inode, "ids"), snapshots),
|
||||
}
|
||||
|
||||
root.MetaDir = NewMetaDir(root, rootInode, entries)
|
||||
|
|
|
@ -66,6 +66,26 @@ func NewSnapshotsDir(root *Root, inode uint64, snapshots restic.Snapshots) *Snap
|
|||
return d
|
||||
}
|
||||
|
||||
// NewSnapshotsIDSDir returns a new directory containing snapshots named by ids.
|
||||
func NewSnapshotsIDSDir(root *Root, inode uint64, snapshots restic.Snapshots) *SnapshotsDir {
|
||||
debug.Log("create snapshots ids dir with %d snapshots, inode %d", len(snapshots), inode)
|
||||
d := &SnapshotsDir{
|
||||
root: root,
|
||||
inode: inode,
|
||||
snapshots: snapshots,
|
||||
names: make(map[string]*restic.Snapshot, len(snapshots)),
|
||||
}
|
||||
|
||||
for _, sn := range snapshots {
|
||||
name := sn.ID().Str()
|
||||
|
||||
d.names[name] = sn
|
||||
debug.Log(" add snapshot %v", name)
|
||||
}
|
||||
|
||||
return d
|
||||
}
|
||||
|
||||
// Attr returns the attributes for the root node.
|
||||
func (d *SnapshotsDir) Attr(ctx context.Context, attr *fuse.Attr) error {
|
||||
attr.Inode = d.inode
|
||||
|
|
Loading…
Reference in a new issue