Work in progress
This commit is contained in:
parent
dcec6402c4
commit
57fa972b78
4
dir.go
4
dir.go
@ -54,7 +54,7 @@ func (this *versionedDir) createDir(name string) (*versionedDir, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
node, err := newVersionedNode(childPath, this.node.ver)
|
||||
node, err := newVersionedNode(childPath, this.node.parent, this.node.ver)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -73,7 +73,7 @@ func (this *versionedDir) createFile(name string, flags int) (*versionedFile, er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
node, err := newVersionedNode(childPath, this.node.ver)
|
||||
node, err := newVersionedNode(childPath, this.node.parent, this.node.ver)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
15
node.go
15
node.go
@ -33,25 +33,30 @@ import (
|
||||
type versionedNode struct {
|
||||
path string
|
||||
info os.FileInfo
|
||||
ver *version
|
||||
parent *versionedNode
|
||||
shadow *versionedNode
|
||||
ver *version
|
||||
}
|
||||
|
||||
type versionedNodeMap map[string]*versionedNode
|
||||
|
||||
func newVersionedNode(path string, ver *version) (*versionedNode, error) {
|
||||
func newVersionedNode(path string, parent *versionedNode, ver *version) (*versionedNode, error) {
|
||||
info, err := os.Stat(ver.rebasePath(path))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return newVersionedNodeStat(path, ver, info), nil
|
||||
return newVersionedNodeStat(path, parent, ver, info), nil
|
||||
}
|
||||
|
||||
func newVersionedNodeStat(path string, ver *version, info os.FileInfo) *versionedNode {
|
||||
return &versionedNode{path, info, ver, nil}
|
||||
func newVersionedNodeStat(path string, parent *versionedNode, ver *version, info os.FileInfo) *versionedNode {
|
||||
return &versionedNode{path, info, parent, nil, ver}
|
||||
}
|
||||
|
||||
// func (this *versionedNode) version() (*versionedNode, error) {
|
||||
// return nil, nil
|
||||
// }
|
||||
|
||||
func (this *versionedNode) setAttr(req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error {
|
||||
if req.Valid&fuse.SetattrMode != 0 {
|
||||
if err := os.Chmod(this.rebasedPath(), req.Mode); err != nil {
|
||||
|
14
version.go
14
version.go
@ -62,12 +62,12 @@ func newVersion(base string, timestamp time.Time, allocator InodeAllocator, pare
|
||||
return ver, nil
|
||||
}
|
||||
|
||||
func (this *version) scanDir(path string) (versionedNodeMap, error) {
|
||||
func (this *version) scanNode(node *versionedNode) (versionedNodeMap, error) {
|
||||
var baseNodes versionedNodeMap
|
||||
if this.parent != nil {
|
||||
var err error
|
||||
|
||||
baseNodes, err = this.parent.scanDir(path)
|
||||
baseNodes, err = this.parent.scanNode(node)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -77,7 +77,7 @@ func (this *version) scanDir(path string) (versionedNodeMap, error) {
|
||||
|
||||
ownNodes := make(versionedNodeMap)
|
||||
{
|
||||
infos, err := ioutil.ReadDir(this.rebasePath(path))
|
||||
infos, err := ioutil.ReadDir(this.rebasePath(node.path))
|
||||
if !os.IsNotExist(err) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -85,8 +85,8 @@ func (this *version) scanDir(path string) (versionedNodeMap, error) {
|
||||
|
||||
for _, info := range infos {
|
||||
childName := info.Name()
|
||||
childPath := filepath.Join(path, childName)
|
||||
ownNodes[childName] = newVersionedNodeStat(childPath, this, info)
|
||||
childPath := filepath.Join(node.path, childName)
|
||||
ownNodes[childName] = newVersionedNodeStat(childPath, node, this, info)
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ func (this *version) scanDir(path string) (versionedNodeMap, error) {
|
||||
}
|
||||
|
||||
func (this *version) buildVerDir(dir *versionedDir) error {
|
||||
nodes, err := this.scanDir(dir.node.path)
|
||||
nodes, err := this.scanNode(dir.node)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -128,7 +128,7 @@ func (this *version) buildVerDir(dir *versionedDir) error {
|
||||
}
|
||||
|
||||
func (this *version) resolve() error {
|
||||
node, err := newVersionedNode("/", this)
|
||||
node, err := newVersionedNode("/", nil, this)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user