mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 08:44:02 +00:00
Merge pull request #3036 from greatroar/refactor-fuse
Clean up internal/fuse
This commit is contained in:
commit
8fa64a8f99
@ -27,7 +27,6 @@ type Config struct {
|
|||||||
type Root struct {
|
type Root struct {
|
||||||
repo restic.Repository
|
repo restic.Repository
|
||||||
cfg Config
|
cfg Config
|
||||||
inode uint64
|
|
||||||
blobCache *bloblru.Cache
|
blobCache *bloblru.Cache
|
||||||
|
|
||||||
*SnapshotsDir
|
*SnapshotsDir
|
||||||
@ -50,7 +49,6 @@ func NewRoot(repo restic.Repository, cfg Config) *Root {
|
|||||||
|
|
||||||
root := &Root{
|
root := &Root{
|
||||||
repo: repo,
|
repo: repo,
|
||||||
inode: rootInode,
|
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
blobCache: bloblru.New(blobCacheSize),
|
blobCache: bloblru.New(blobCacheSize),
|
||||||
}
|
}
|
||||||
@ -70,7 +68,7 @@ func NewRoot(repo restic.Repository, cfg Config) *Root {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
root.SnapshotsDir = NewSnapshotsDir(root, rootInode, NewSnapshotsDirStructure(root, cfg.PathTemplates, cfg.TimeTemplate), "")
|
root.SnapshotsDir = NewSnapshotsDir(root, rootInode, rootInode, NewSnapshotsDirStructure(root, cfg.PathTemplates, cfg.TimeTemplate), "")
|
||||||
|
|
||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
type SnapshotsDir struct {
|
type SnapshotsDir struct {
|
||||||
root *Root
|
root *Root
|
||||||
inode uint64
|
inode uint64
|
||||||
|
parentInode uint64
|
||||||
dirStruct *SnapshotsDirStructure
|
dirStruct *SnapshotsDirStructure
|
||||||
prefix string
|
prefix string
|
||||||
}
|
}
|
||||||
@ -28,11 +29,12 @@ var _ = fs.HandleReadDirAller(&SnapshotsDir{})
|
|||||||
var _ = fs.NodeStringLookuper(&SnapshotsDir{})
|
var _ = fs.NodeStringLookuper(&SnapshotsDir{})
|
||||||
|
|
||||||
// NewSnapshotsDir returns a new directory structure containing snapshots and "latest" links
|
// NewSnapshotsDir returns a new directory structure containing snapshots and "latest" links
|
||||||
func NewSnapshotsDir(root *Root, inode uint64, dirStruct *SnapshotsDirStructure, prefix string) *SnapshotsDir {
|
func NewSnapshotsDir(root *Root, inode, parentInode uint64, dirStruct *SnapshotsDirStructure, prefix string) *SnapshotsDir {
|
||||||
debug.Log("create snapshots dir, inode %d", inode)
|
debug.Log("create snapshots dir, inode %d", inode)
|
||||||
return &SnapshotsDir{
|
return &SnapshotsDir{
|
||||||
root: root,
|
root: root,
|
||||||
inode: inode,
|
inode: inode,
|
||||||
|
parentInode: parentInode,
|
||||||
dirStruct: dirStruct,
|
dirStruct: dirStruct,
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
}
|
}
|
||||||
@ -68,7 +70,7 @@ func (d *SnapshotsDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
|||||||
Type: fuse.DT_Dir,
|
Type: fuse.DT_Dir,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Inode: d.root.inode,
|
Inode: d.parentInode,
|
||||||
Name: "..",
|
Name: "..",
|
||||||
Type: fuse.DT_Dir,
|
Type: fuse.DT_Dir,
|
||||||
},
|
},
|
||||||
@ -107,7 +109,7 @@ func (d *SnapshotsDir) Lookup(ctx context.Context, name string) (fs.Node, error)
|
|||||||
} else if entry.snapshot != nil {
|
} else if entry.snapshot != nil {
|
||||||
return newDirFromSnapshot(ctx, d.root, fs.GenerateDynamicInode(d.inode, name), entry.snapshot)
|
return newDirFromSnapshot(ctx, d.root, fs.GenerateDynamicInode(d.inode, name), entry.snapshot)
|
||||||
} else {
|
} else {
|
||||||
return NewSnapshotsDir(d.root, fs.GenerateDynamicInode(d.inode, name), d.dirStruct, d.prefix+"/"+name), nil
|
return NewSnapshotsDir(d.root, fs.GenerateDynamicInode(d.inode, name), d.inode, d.dirStruct, d.prefix+"/"+name), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user