diff --git a/internal/fuse/root.go b/internal/fuse/root.go index 527b61816..d59e36f58 100644 --- a/internal/fuse/root.go +++ b/internal/fuse/root.go @@ -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) diff --git a/internal/fuse/snapshots_dir.go b/internal/fuse/snapshots_dir.go index fc0f63825..467b0ceae 100644 --- a/internal/fuse/snapshots_dir.go +++ b/internal/fuse/snapshots_dir.go @@ -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