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

View File

@ -33,11 +33,17 @@ import (
// versionedNode // versionedNode
// //
const (
NodeModified = 1 << iota
NodeDeleted
)
type versionedNode struct { type versionedNode struct {
path string path string
info os.FileInfo info os.FileInfo
ver *version ver *version
parent *versionedNode parent *versionedNode
flags uint
} }
type versionedNodeMap map[string]*versionedNode 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 { 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 { 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 return nil, err
} }
ver := &version{ return &version{base, parent, timestamp, meta, nil, db}, nil
base: base,
parent: parent,
timestamp: timestamp,
meta: meta,
db: db}
return ver, nil
} }
func (this *version) scanDir(path string) (versionedNodeMap, error) { func (this *version) scanDir(path string) (versionedNodeMap, error) {