mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
Merge branch 'master' of https://github.com/foomo/ContentServer
This commit is contained in:
commit
f2c1053fb8
@ -59,7 +59,7 @@ func log(msg string, level int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetLogLevel(level int) bool {
|
func SetLogLevel(level int) bool {
|
||||||
if level > LOG_LEVEL_ERROR && level <= LOG_LEVEL_DEBUG {
|
if level >= LOG_LEVEL_ERROR && level <= LOG_LEVEL_DEBUG {
|
||||||
logLevel = level
|
logLevel = level
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -147,7 +147,7 @@ func (node *RepoNode) IsOneOfTheseMimeTypes(mimeTypes []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (node *RepoNode) CanBeAccessedByGroups(groups []string) bool {
|
func (node *RepoNode) CanBeAccessedByGroups(groups []string) bool {
|
||||||
if len(groups) == 0 {
|
if len(groups) == 0 || len(node.Groups) == 0 {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
// @todo is there sth like in_array ... or some array intersection
|
// @todo is there sth like in_array ... or some array intersection
|
||||||
|
|||||||
@ -214,6 +214,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 {
|
func (repo *Repo) Update() *responses.Update {
|
||||||
updateResponse := responses.NewUpdate()
|
updateResponse := responses.NewUpdate()
|
||||||
|
|
||||||
@ -225,22 +242,7 @@ func (repo *Repo) Update() *responses.Update {
|
|||||||
startTimeOwn := time.Now()
|
startTimeOwn := time.Now()
|
||||||
updateResponse.Success = ok
|
updateResponse.Success = ok
|
||||||
if ok {
|
if ok {
|
||||||
|
repo.Load(newNode)
|
||||||
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
|
|
||||||
|
|
||||||
updateResponse.Stats.NumberOfNodes = len(repo.Directory)
|
updateResponse.Stats.NumberOfNodes = len(repo.Directory)
|
||||||
updateResponse.Stats.NumberOfURIs = len(repo.URIDirectory)
|
updateResponse.Stats.NumberOfURIs = len(repo.URIDirectory)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
package requests
|
package requests
|
||||||
|
|
||||||
|
type Defaults struct {
|
||||||
|
Region string `json:"region"`
|
||||||
|
Language string `json:"language"`
|
||||||
|
}
|
||||||
|
|
||||||
type Env struct {
|
type Env struct {
|
||||||
Defaults struct {
|
Defaults *Defaults `json:"defaults"`
|
||||||
Region string `json:"region"`
|
Groups []string `json:"groups"`
|
||||||
Language string `json:"language"`
|
State string
|
||||||
} `json:"defaults"`
|
Data interface{} `json:"data"`
|
||||||
Groups []string `json:"groups"`
|
|
||||||
State string
|
|
||||||
Data interface{} `json:"data"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user