mirror of
https://github.com/jech/galene.git
synced 2024-11-10 02:35:58 +01:00
Check all group files on startup, not just the toplevel directory.
This commit is contained in:
parent
82827453f0
commit
61990ff1ef
1 changed files with 35 additions and 26 deletions
|
@ -821,32 +821,41 @@ func GetPublic() []Public {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadPublicGroups() {
|
func ReadPublicGroups() {
|
||||||
dir, err := os.Open(Directory)
|
err := filepath.Walk(
|
||||||
|
Directory,
|
||||||
|
func(path string, fi os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
log.Printf("Group file %v: %v", path, err)
|
||||||
}
|
}
|
||||||
defer dir.Close()
|
if fi.IsDir() {
|
||||||
|
return nil
|
||||||
fis, err := dir.Readdir(-1)
|
}
|
||||||
|
filename, err := filepath.Rel(Directory, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("readPublicGroups: %v", err)
|
log.Printf("Group file %v: %v", path, err)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
if !strings.HasSuffix(filename, ".json") {
|
||||||
for _, fi := range fis {
|
log.Printf(
|
||||||
if !strings.HasSuffix(fi.Name(), ".json") {
|
"Unexpected extension for group file %v",
|
||||||
continue
|
path,
|
||||||
|
)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
name := fi.Name()[:len(fi.Name())-5]
|
name := filename[:len(filename)-5]
|
||||||
desc, err := GetDescription(name)
|
desc, err := GetDescription(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) {
|
log.Printf("Group file %v: %v", path, err)
|
||||||
log.Printf("Reading group %v: %v", name, err)
|
return nil
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
if desc.Public {
|
if desc.Public {
|
||||||
Add(name, desc)
|
Add(name, desc)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Couldn't read groups: %v", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue