Cleanup
This commit is contained in:
parent
2278f5710b
commit
facabaf563
38
node.go
38
node.go
@ -41,8 +41,6 @@ type versionedNode struct {
|
||||
versioned bool
|
||||
}
|
||||
|
||||
type versionedNodeMap map[string]*versionedNode
|
||||
|
||||
func newVersionedNode(path string, ver *version, parent *versionedNode) (*versionedNode, error) {
|
||||
info, err := os.Stat(ver.rebasePath(path))
|
||||
if err != nil {
|
||||
@ -56,21 +54,6 @@ func newVersionedNodeStat(path string, ver *version, parent *versionedNode, info
|
||||
return &versionedNode{path, info, ver, parent, false}
|
||||
}
|
||||
|
||||
func (this *versionedNode) remove() error {
|
||||
ver := this.ver
|
||||
|
||||
if this.versioned {
|
||||
if err := os.Remove(this.rebasedPath()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ver = ver.parent
|
||||
}
|
||||
|
||||
ver.removePath(this.path)
|
||||
return 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 {
|
||||
@ -124,6 +107,21 @@ func (this *versionedNode) sync() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *versionedNode) remove() error {
|
||||
ver := this.ver
|
||||
|
||||
if this.versioned {
|
||||
if err := os.Remove(this.rebasedPath()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ver = ver.parent
|
||||
}
|
||||
|
||||
ver.removePath(this.path)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *versionedNode) rebasedPath() string {
|
||||
return this.ver.rebasePath(this.path)
|
||||
}
|
||||
@ -156,3 +154,9 @@ func (this *versionedNode) attr(attr *fuse.Attr) {
|
||||
attr.Gid, attr.Uid = this.owner()
|
||||
attr.Rdev = uint32(stat.Rdev)
|
||||
}
|
||||
|
||||
//
|
||||
// versionedNodeMap
|
||||
//
|
||||
|
||||
type versionedNodeMap map[string]*versionedNode
|
||||
|
22
version.go
22
version.go
@ -32,7 +32,6 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -151,27 +150,12 @@ func (this *version) finalize() error {
|
||||
return this.meta.save()
|
||||
}
|
||||
|
||||
func (this *version) dump(root *versionedDir, depth int) {
|
||||
indent := strings.Repeat("\t", depth)
|
||||
for name, dir := range root.dirs {
|
||||
fmt.Printf("%s+ %s [%s@%x]\n", indent, name, dir.node.path, this.timestamp.Unix())
|
||||
this.dump(dir, depth+1)
|
||||
}
|
||||
for name, file := range root.files {
|
||||
fmt.Printf("%s- %s [%s@%x]\n", indent, name, file.node.path, this.timestamp.Unix())
|
||||
}
|
||||
}
|
||||
|
||||
func (this *version) dumpRoot() {
|
||||
this.dump(this.root, 0)
|
||||
}
|
||||
|
||||
func (this *version) Root() (fs.Node, error) {
|
||||
return this.root, nil
|
||||
}
|
||||
|
||||
//
|
||||
// version helpers
|
||||
// versionList
|
||||
//
|
||||
|
||||
type versionList []*version
|
||||
@ -188,6 +172,10 @@ func (this versionList) Less(i, j int) bool {
|
||||
return this[i].timestamp.Unix() < this[j].timestamp.Unix()
|
||||
}
|
||||
|
||||
//
|
||||
// version helpers
|
||||
//
|
||||
|
||||
func buildNewVersion(base string) error {
|
||||
name := buildVerName(time.Now())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user