Generalize fuse snapshot dirs implemetation

+ allow "/" in tags and snapshot template
This commit is contained in:
Alexander Weiss
2020-09-02 21:27:24 +02:00
committed by Michael Eischer
parent 696c18e031
commit 57f4003f2f
5 changed files with 434 additions and 470 deletions

View File

@@ -5,7 +5,6 @@ package fuse
import (
"os"
"time"
"github.com/restic/restic/internal/bloblru"
"github.com/restic/restic/internal/debug"
@@ -28,13 +27,9 @@ type Root struct {
repo restic.Repository
cfg Config
inode uint64
snapshots restic.Snapshots
blobCache *bloblru.Cache
snCount int
lastCheck time.Time
*MetaDir
*SnapshotsDir
uid, gid uint32
}
@@ -64,14 +59,14 @@ func NewRoot(repo restic.Repository, cfg Config) *Root {
root.gid = uint32(os.Getgid())
}
entries := map[string]fs.Node{
"snapshots": NewSnapshotsDir(root, fs.GenerateDynamicInode(root.inode, "snapshots"), "", ""),
"tags": NewTagsDir(root, fs.GenerateDynamicInode(root.inode, "tags")),
"hosts": NewHostsDir(root, fs.GenerateDynamicInode(root.inode, "hosts")),
"ids": NewSnapshotsIDSDir(root, fs.GenerateDynamicInode(root.inode, "ids")),
paths := []string{
"ids/%i",
"snapshots/%T",
"hosts/%h/%T",
"tags/%t/%T",
}
root.MetaDir = NewMetaDir(root, rootInode, entries)
root.SnapshotsDir = NewSnapshotsDir(root, rootInode, NewSnapshotsDirStructure(root, paths, cfg.SnapshotTemplate), "")
return root
}