This commit is contained in:
Alex Yatskov 2015-05-28 19:10:16 +09:00
parent 55d6408a17
commit a4d81518d6
3 changed files with 14 additions and 14 deletions

View File

@ -81,7 +81,7 @@ func (this *database) buildVersions(base string) ([]*version, error) {
return nil, err
}
var parent *version
var prev *version
var vers []*version
for _, node := range nodes {
@ -94,17 +94,17 @@ func (this *database) buildVersions(base string) ([]*version, error) {
return nil, err
}
ver, err := newVersion(path.Join(base, node.Name()), timestamp, parent)
ver, err := newVersion(path.Join(base, node.Name()), timestamp, prev)
if err != nil {
return nil, err
}
vers = append(vers, ver)
parent = ver
prev = ver
}
for _, ver := range vers {
ver.terminus = vers[len(vers)-1]
ver.last = vers[len(vers)-1]
}
return vers, nil

View File

@ -37,7 +37,7 @@ type versionedNode struct {
path string
info os.FileInfo
parent *versionedNode
shadow *versionedNode
prev *versionedNode
ver *version
}
@ -114,11 +114,11 @@ func (this *versionedNode) rebasedPath() string {
}
func (this *versionedNode) rebasedTermPath() string {
if this.ver.terminus == nil {
if this.ver.last == nil {
return this.rebasedPath()
}
return this.ver.terminus.rebasePath(this.path)
return this.ver.last.rebasePath(this.path)
}
func (this *versionedNode) owner() (gid, uid uint32) {

View File

@ -42,14 +42,14 @@ import (
type version struct {
base string
parent *version
terminus *version
prev *version
last *version
timestamp time.Time
meta *versionMetadata
root *versionedDir
}
func newVersion(base string, timestamp time.Time, parent *version) (*version, error) {
func newVersion(base string, timestamp time.Time, prev *version) (*version, error) {
meta, err := newVersionMetadata(filepath.Join(base, "meta.json"))
if err != nil {
return nil, err
@ -57,7 +57,7 @@ func newVersion(base string, timestamp time.Time, parent *version) (*version, er
ver := &version{
base: base,
parent: parent,
prev: prev,
timestamp: timestamp,
meta: meta}
@ -66,10 +66,10 @@ func newVersion(base string, timestamp time.Time, parent *version) (*version, er
func (this *version) scanNode(node *versionedNode) (versionedNodeMap, error) {
var baseNodes versionedNodeMap
if this.parent != nil {
if this.prev != nil {
var err error
baseNodes, err = this.parent.scanNode(node)
baseNodes, err = this.prev.scanNode(node)
if err != nil {
return nil, err
}
@ -100,7 +100,7 @@ func (this *version) scanNode(node *versionedNode) (versionedNodeMap, error) {
}
for ownName, ownNode := range ownNodes {
ownNode.shadow = baseNodes[ownName]
ownNode.prev = baseNodes[ownName]
baseNodes[ownName] = ownNode
}