From c141246e7c17cfbfb5454337c213f200ff4caefd Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 16 Jun 2015 17:34:10 +0900 Subject: [PATCH] Cleanup --- dir.go | 8 +++----- node.go | 8 +++++++- version.go | 9 +-------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/dir.go b/dir.go index e99f71e..bbacb79 100644 --- a/dir.go +++ b/dir.go @@ -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 } diff --git a/node.go b/node.go index 4cc8e27..ec1f16a 100644 --- a/node.go +++ b/node.go @@ -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 { diff --git a/version.go b/version.go index 2c77dab..5129431 100644 --- a/version.go +++ b/version.go @@ -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) {