Work in progress
This commit is contained in:
parent
a96c0295b9
commit
920dc8c841
12
dir.go
12
dir.go
@ -29,12 +29,20 @@ import (
|
||||
)
|
||||
|
||||
type versionedDir struct {
|
||||
dirs map[string]versionedDir
|
||||
files map[string]versionedFile
|
||||
dirs map[string]*versionedDir
|
||||
files map[string]*versionedFile
|
||||
node versionedNode
|
||||
inode uint64
|
||||
}
|
||||
|
||||
func newVersionedDir(node versionedNode, inode uint64) *versionedDir {
|
||||
return &versionedDir{
|
||||
dirs: make(map[string]*versionedDir),
|
||||
files: make(map[string]*versionedFile),
|
||||
node: node,
|
||||
inode: inode}
|
||||
}
|
||||
|
||||
func (this versionedDir) Attr(attr *fuse.Attr) {
|
||||
attr.Mode = this.node.info.Mode()
|
||||
attr.Inode = this.inode
|
||||
|
4
file.go
4
file.go
@ -32,6 +32,10 @@ type versionedFile struct {
|
||||
inode uint64
|
||||
}
|
||||
|
||||
func newVersionedFile(node versionedNode, inode uint64) *versionedFile {
|
||||
return &versionedFile{node: node, inode: inode}
|
||||
}
|
||||
|
||||
func (this versionedFile) Attr(attr *fuse.Attr) {
|
||||
attr.Mode = this.node.info.Mode()
|
||||
attr.Inode = this.inode
|
||||
|
22
version.go
22
version.go
@ -48,7 +48,7 @@ type version struct {
|
||||
parent *version
|
||||
timestamp time.Time
|
||||
meta versionMetadata
|
||||
root versionedDir
|
||||
root *versionedDir
|
||||
inodeCnt uint64
|
||||
}
|
||||
|
||||
@ -107,9 +107,8 @@ func (this *version) scanDir(path string) (map[string]versionedNode, error) {
|
||||
|
||||
for _, node := range nodes {
|
||||
name := node.Name()
|
||||
ownNodes[name] = versionedNode{
|
||||
info: node,
|
||||
path: filepath.Join(fullPath, name)}
|
||||
subPath := filepath.Join(fullPath, name)
|
||||
ownNodes[name] = versionedNode{subPath, node}
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,16 +131,15 @@ func (this *version) buildDir(path string, dir *versionedDir) error {
|
||||
|
||||
for name, node := range nodes {
|
||||
if node.info.IsDir() {
|
||||
subDir := versionedDir{node: node, inode: this.allocInode()}
|
||||
|
||||
subDir := newVersionedDir(node, this.allocInode())
|
||||
subDirPath := filepath.Join(path, name)
|
||||
if err := this.buildDir(subDirPath, &subDir); err != nil {
|
||||
if err := this.buildDir(subDirPath, subDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dir.dirs[name] = subDir
|
||||
} else {
|
||||
dir.files[name] = versionedFile{node: node, inode: this.allocInode()}
|
||||
dir.files[name] = newVersionedFile(node, this.allocInode())
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,11 +152,11 @@ func (this *version) scanFs() error {
|
||||
return err
|
||||
}
|
||||
|
||||
this.root = versionedDir{
|
||||
node: versionedNode{path: this.rootPath(), info: node},
|
||||
inode: this.allocInode()}
|
||||
this.root = newVersionedDir(
|
||||
versionedNode{path: this.rootPath(), info: node},
|
||||
this.allocInode())
|
||||
|
||||
return this.buildDir(this.rootPath(), &this.root)
|
||||
return this.buildDir(this.rootPath(), this.root)
|
||||
}
|
||||
|
||||
func (this *version) loadMetadata() error {
|
||||
|
Loading…
Reference in New Issue
Block a user