Fixing version scanning issues

This commit is contained in:
Alex Yatskov 2015-06-16 19:13:29 +09:00
parent b951af38f1
commit c062312f04
2 changed files with 10 additions and 6 deletions

View File

@ -88,9 +88,7 @@ func (this *database) buildVersions(base string) (versionList, error) {
return nil, err return nil, err
} }
var parent *version
var vers versionList var vers versionList
for _, node := range nodes { for _, node := range nodes {
if !node.IsDir() { if !node.IsDir() {
continue continue
@ -101,16 +99,22 @@ func (this *database) buildVersions(base string) (versionList, error) {
return nil, err return nil, err
} }
ver, err := newVersion(path.Join(base, node.Name()), timestamp, this, parent) ver, err := newVersion(path.Join(base, node.Name()), timestamp, this)
if err != nil { if err != nil {
return nil, err return nil, err
} }
vers = append(vers, ver) vers = append(vers, ver)
parent = ver
} }
sort.Sort(vers) sort.Sort(vers)
var parentVer *version
for _, ver := range vers {
ver.parent = parentVer
parentVer = ver
}
return vers, nil return vers, nil
} }

View File

@ -48,13 +48,13 @@ type version struct {
db *database db *database
} }
func newVersion(base string, timestamp time.Time, db *database, parent *version) (*version, error) { func newVersion(base string, timestamp time.Time, db *database) (*version, error) {
meta, err := newVersionMetadata(filepath.Join(base, "meta.json")) meta, err := newVersionMetadata(filepath.Join(base, "meta.json"))
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &version{base, parent, timestamp, meta, nil, db}, nil return &version{base, nil, timestamp, meta, nil, db}, nil
} }
func (this *version) scanDir(path string) (versionedNodeMap, error) { func (this *version) scanDir(path string) (versionedNodeMap, error) {