This commit is contained in:
Alex Yatskov 2015-06-16 17:34:10 +09:00
parent f81ad172f7
commit c141246e7c
3 changed files with 11 additions and 14 deletions

8
dir.go
View File

@ -41,7 +41,6 @@ type versionedDir struct {
node *versionedNode
inode uint64
parent *versionedDir
dirty bool
}
func newVersionedDir(node *versionedNode, parent *versionedDir) *versionedDir {
@ -50,12 +49,11 @@ func newVersionedDir(node *versionedNode, parent *versionedDir) *versionedDir {
files: make(map[string]*versionedFile),
node: node,
inode: allocInode(),
parent: parent,
dirty: false}
parent: parent}
}
func (this *versionedDir) version() error {
if this.dirty {
if this.node.flags&NodeModified == NodeModified {
return nil
}
@ -71,8 +69,8 @@ func (this *versionedDir) version() error {
return err
}
node.flags |= NodeModified
this.node = node
this.dirty = true
return nil
}

View File

@ -33,11 +33,17 @@ import (
// versionedNode
//
const (
NodeModified = 1 << iota
NodeDeleted
)
type versionedNode struct {
path string
info os.FileInfo
ver *version
parent *versionedNode
flags uint
}
type versionedNodeMap map[string]*versionedNode
@ -52,7 +58,7 @@ func newVersionedNode(path string, ver *version, parent *versionedNode) (*versio
}
func newVersionedNodeStat(path string, ver *version, parent *versionedNode, info os.FileInfo) *versionedNode {
return &versionedNode{path, info, ver, parent}
return &versionedNode{path, info, ver, parent, 0}
}
func (this *versionedNode) setAttr(req *fuse.SetattrRequest, resp *fuse.SetattrResponse) error {

View File

@ -55,14 +55,7 @@ func newVersion(base string, timestamp time.Time, db *database, parent *version)
return nil, err
}
ver := &version{
base: base,
parent: parent,
timestamp: timestamp,
meta: meta,
db: db}
return ver, nil
return &version{base, parent, timestamp, meta, nil, db}, nil
}
func (this *version) scanDir(path string) (versionedNodeMap, error) {