Make snapshots dirs in mount command customizable

This commit is contained in:
Alexander Weiss
2020-09-03 20:31:57 +02:00
committed by Michael Eischer
parent 57f4003f2f
commit 1751afae26
4 changed files with 63 additions and 24 deletions

View File

@@ -15,11 +15,12 @@ import (
// Config holds settings for the fuse mount.
type Config struct {
OwnerIsRoot bool
Hosts []string
Tags []restic.TagList
Paths []string
SnapshotTemplate string
OwnerIsRoot bool
Hosts []string
Tags []restic.TagList
Paths []string
TimeTemplate string
PathTemplates []string
}
// Root is the root node of the fuse mount of a repository.
@@ -59,14 +60,17 @@ func NewRoot(repo restic.Repository, cfg Config) *Root {
root.gid = uint32(os.Getgid())
}
paths := []string{
"ids/%i",
"snapshots/%T",
"hosts/%h/%T",
"tags/%t/%T",
// set defaults, if PathTemplates is not set
if len(cfg.PathTemplates) == 0 {
cfg.PathTemplates = []string{
"ids/%i",
"snapshots/%T",
"hosts/%h/%T",
"tags/%t/%T",
}
}
root.SnapshotsDir = NewSnapshotsDir(root, rootInode, NewSnapshotsDirStructure(root, paths, cfg.SnapshotTemplate), "")
root.SnapshotsDir = NewSnapshotsDir(root, rootInode, NewSnapshotsDirStructure(root, cfg.PathTemplates, cfg.TimeTemplate), "")
return root
}