mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
added maxGetURIForNodeRecursionLevel
This commit is contained in:
parent
09edb5cd09
commit
db94db5082
16
repo/repo.go
16
repo/repo.go
@ -245,22 +245,28 @@ func (repo *Repo) resolveContent(dimensions []string, URI string) (resolved bool
|
||||
return
|
||||
}
|
||||
|
||||
func (repo *Repo) getURIForNode(dimension string, repoNode *content.RepoNode) string {
|
||||
const maxGetURIForNodeRecursionLevel = 1000
|
||||
|
||||
func (repo *Repo) getURIForNode(dimension string, repoNode *content.RepoNode, recursionLevel int64) (uri string) {
|
||||
if len(repoNode.LinkID) == 0 {
|
||||
return repoNode.URI
|
||||
uri = repoNode.URI
|
||||
return
|
||||
}
|
||||
linkedNode, ok := repo.Directory[dimension].Directory[repoNode.LinkID]
|
||||
if ok {
|
||||
return repo.getURIForNode(dimension, linkedNode)
|
||||
if recursionLevel > maxGetURIForNodeRecursionLevel {
|
||||
log.Error("maxGetURIForNodeRecursionLevel reached for", repoNode.ID, "link id", repoNode.LinkID, "in dimension", dimension)
|
||||
return ""
|
||||
}
|
||||
return repo.getURIForNode(dimension, linkedNode, recursionLevel+1)
|
||||
}
|
||||
return ""
|
||||
return
|
||||
}
|
||||
|
||||
func (repo *Repo) getURI(dimension string, id string) string {
|
||||
repoNode, ok := repo.Directory[dimension].Directory[id]
|
||||
if ok {
|
||||
return repo.getURIForNode(dimension, repoNode)
|
||||
return repo.getURIForNode(dimension, repoNode, 0)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user