mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
repo code cleanup
This commit is contained in:
parent
f0df9a6322
commit
dc047baf32
@ -11,9 +11,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const historyRepoJSONPrefix = "contentserver-repo-"
|
const (
|
||||||
const historyRepoJSONSuffix = ".json"
|
historyRepoJSONPrefix = "contentserver-repo-"
|
||||||
const maxHistoryVersions = 20
|
historyRepoJSONSuffix = ".json"
|
||||||
|
maxHistoryVersions = 20
|
||||||
|
)
|
||||||
|
|
||||||
type history struct {
|
type history struct {
|
||||||
varDir string
|
varDir string
|
||||||
|
|||||||
15
repo/repo.go
15
repo/repo.go
@ -12,6 +12,8 @@ import (
|
|||||||
"github.com/foomo/contentserver/responses"
|
"github.com/foomo/contentserver/responses"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const maxGetURIForNodeRecursionLevel = 1000
|
||||||
|
|
||||||
// Dimension dimension in a repo
|
// Dimension dimension in a repo
|
||||||
type Dimension struct {
|
type Dimension struct {
|
||||||
Directory map[string]*content.RepoNode
|
Directory map[string]*content.RepoNode
|
||||||
@ -70,8 +72,11 @@ func (repo *Repo) GetNodes(r *requests.Nodes) map[string]*content.Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repo) getNodes(nodeRequests map[string]*requests.Node, env *requests.Env) map[string]*content.Node {
|
func (repo *Repo) getNodes(nodeRequests map[string]*requests.Node, env *requests.Env) map[string]*content.Node {
|
||||||
nodes := map[string]*content.Node{}
|
|
||||||
path := []*content.Item{}
|
var (
|
||||||
|
nodes = map[string]*content.Node{}
|
||||||
|
path = []*content.Item{}
|
||||||
|
)
|
||||||
for nodeName, nodeRequest := range nodeRequests {
|
for nodeName, nodeRequest := range nodeRequests {
|
||||||
log.Debug(" adding node " + nodeName + " " + nodeRequest.ID)
|
log.Debug(" adding node " + nodeName + " " + nodeRequest.ID)
|
||||||
|
|
||||||
@ -223,10 +228,6 @@ func (repo *Repo) Update() (updateResponse *responses.Update) {
|
|||||||
// resolveContent find content in a repository
|
// resolveContent find content in a repository
|
||||||
func (repo *Repo) resolveContent(dimensions []string, URI string) (resolved bool, resolvedURI string, resolvedDimension string, repoNode *content.RepoNode) {
|
func (repo *Repo) resolveContent(dimensions []string, URI string) (resolved bool, resolvedURI string, resolvedDimension string, repoNode *content.RepoNode) {
|
||||||
parts := strings.Split(URI, content.PathSeparator)
|
parts := strings.Split(URI, content.PathSeparator)
|
||||||
resolved = false
|
|
||||||
resolvedURI = ""
|
|
||||||
resolvedDimension = ""
|
|
||||||
repoNode = nil
|
|
||||||
log.Debug("repo.ResolveContent: " + URI)
|
log.Debug("repo.ResolveContent: " + URI)
|
||||||
for i := len(parts); i > 0; i-- {
|
for i := len(parts); i > 0; i-- {
|
||||||
testURI := strings.Join(parts[0:i], content.PathSeparator)
|
testURI := strings.Join(parts[0:i], content.PathSeparator)
|
||||||
@ -253,8 +254,6 @@ func (repo *Repo) resolveContent(dimensions []string, URI string) (resolved bool
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxGetURIForNodeRecursionLevel = 1000
|
|
||||||
|
|
||||||
func (repo *Repo) getURIForNode(dimension string, repoNode *content.RepoNode, recursionLevel int64) (uri string) {
|
func (repo *Repo) getURIForNode(dimension string, repoNode *content.RepoNode, recursionLevel int64) (uri string) {
|
||||||
if len(repoNode.LinkID) == 0 {
|
if len(repoNode.LinkID) == 0 {
|
||||||
uri = repoNode.URI
|
uri = repoNode.URI
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user