This commit is contained in:
franklin 2014-10-01 15:02:45 +02:00
commit f2c1053fb8
4 changed files with 29 additions and 25 deletions

View File

@ -59,7 +59,7 @@ func log(msg string, level int) string {
}
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
return true
} else {

View File

@ -147,7 +147,7 @@ func (node *RepoNode) IsOneOfTheseMimeTypes(mimeTypes []string) bool {
}
func (node *RepoNode) CanBeAccessedByGroups(groups []string) bool {
if len(groups) == 0 {
if len(groups) == 0 || len(node.Groups) == 0 {
return true
} else {
// @todo is there sth like in_array ... or some array intersection

View File

@ -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 {
updateResponse := responses.NewUpdate()
@ -225,22 +242,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 {

View File

@ -1,13 +1,15 @@
package requests
type Defaults struct {
Region string `json:"region"`
Language string `json:"language"`
}
type Env struct {
Defaults struct {
Region string `json:"region"`
Language string `json:"language"`
} `json:"defaults"`
Groups []string `json:"groups"`
State string
Data interface{} `json:"data"`
Defaults *Defaults `json:"defaults"`
Groups []string `json:"groups"`
State string
Data interface{} `json:"data"`
}
type Node struct {