diff --git a/server/repo/repo.go b/server/repo/repo.go index d27f4df..bfaa874 100644 --- a/server/repo/repo.go +++ b/server/repo/repo.go @@ -31,7 +31,7 @@ func (repo *Repo) ResolveContent(state string, URI string) (resolved bool, resol parts := strings.Split(URI, content.PATH_SEPARATOR) log.Debug("repo.ResolveContent: " + URI) for i := len(parts); i > -1; i-- { - testURI := strings.Join(parts[0:i], content.PATH_SEPARATOR) + testURI := strings.Join(parts[0:i], content.PATH_SEPARATOR) testURIKey := uriKeyForState(state, testURI) log.Debug(" testing" + testURIKey) if repoNode, ok := repo.URIDirectory[testURIKey]; ok { @@ -175,7 +175,7 @@ func (repo *Repo) GetRepo() *content.RepoNode { } func uriKeyForState(state string, uri string) string { - return state + "-" + uri; + return state + "-" + uri } func builDirectory(dirNode *content.RepoNode, directory map[string]*content.RepoNode, uRIDirectory map[string]*content.RepoNode) { @@ -210,6 +210,23 @@ func wireAliases(directory map[string]*content.RepoNode) { } } +func (repo *Repo) Load(newNode *content.RepoNode) { + newNode.WireParents() + + newDirectory := make(map[string]*content.RepoNode) + newURIDirectory := make(map[string]*content.RepoNode) + + builDirectory(newNode, newDirectory, newURIDirectory) + wireAliases(newDirectory) + + // some more validation anyone? + // invalid destination ids + + repo.Node = newNode + repo.Directory = newDirectory + repo.URIDirectory = newURIDirectory +} + func (repo *Repo) Update() *responses.Update { updateResponse := responses.NewUpdate() @@ -221,22 +238,7 @@ func (repo *Repo) Update() *responses.Update { startTimeOwn := time.Now() updateResponse.Success = ok if ok { - - newNode.WireParents() - - newDirectory := make(map[string]*content.RepoNode) - newURIDirectory := make(map[string]*content.RepoNode) - - builDirectory(newNode, newDirectory, newURIDirectory) - wireAliases(newDirectory) - - // some more validation anyone? - // invalid destination ids - - repo.Node = newNode - repo.Directory = newDirectory - repo.URIDirectory = newURIDirectory - + repo.Load(newNode) updateResponse.Stats.NumberOfNodes = len(repo.Directory) updateResponse.Stats.NumberOfURIs = len(repo.URIDirectory) } else {