Adding version terminus

This commit is contained in:
Alex Yatskov 2015-05-28 14:12:27 +09:00
parent 5749d16e4b
commit 2903a5a17f
2 changed files with 8 additions and 2 deletions

View File

@ -94,7 +94,7 @@ func (this *database) buildVersions(base string, names []string) ([]*version, er
return nil, err
}
ver, err := newVersion(path.Join(base, name), timestamp, this, parent)
ver, err := newVersion(path.Join(base, name), timestamp, this, parent, nil)
if err != nil {
return nil, err
}
@ -103,6 +103,10 @@ func (this *database) buildVersions(base string, names []string) ([]*version, er
parent = ver
}
for _, ver := range vers {
ver.terminus = vers[len(vers)-1]
}
return vers, nil
}

View File

@ -35,6 +35,7 @@ import (
type version struct {
base string
parent *version
terminus *version
timestamp time.Time
meta *versionMetadata
root *versionedDir
@ -45,7 +46,7 @@ type InodeAllocator interface {
AllocInode() uint64
}
func newVersion(base string, timestamp time.Time, allocator InodeAllocator, parent *version) (*version, error) {
func newVersion(base string, timestamp time.Time, allocator InodeAllocator, parent, terminus *version) (*version, error) {
meta, err := newVersionMetadata(filepath.Join(base, "meta.json"))
if err != nil {
return nil, err
@ -54,6 +55,7 @@ func newVersion(base string, timestamp time.Time, allocator InodeAllocator, pare
ver := &version{
base: base,
parent: parent,
terminus: terminus,
timestamp: timestamp,
meta: meta,
inodeAloc: allocator}