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() {
|
||||
dir, err := os.Open(Directory)
|
||||
err := filepath.Walk(
|
||||
Directory,
|
||||
func(path string, fi os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return
|
||||
log.Printf("Group file %v: %v", path, err)
|
||||
}
|
||||
defer dir.Close()
|
||||
|
||||
fis, err := dir.Readdir(-1)
|
||||
if fi.IsDir() {
|
||||
return nil
|
||||
}
|
||||
filename, err := filepath.Rel(Directory, path)
|
||||
if err != nil {
|
||||
log.Printf("readPublicGroups: %v", err)
|
||||
return
|
||||
log.Printf("Group file %v: %v", path, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, fi := range fis {
|
||||
if !strings.HasSuffix(fi.Name(), ".json") {
|
||||
continue
|
||||
if !strings.HasSuffix(filename, ".json") {
|
||||
log.Printf(
|
||||
"Unexpected extension for group file %v",
|
||||
path,
|
||||
)
|
||||
return nil
|
||||
}
|
||||
name := fi.Name()[:len(fi.Name())-5]
|
||||
name := filename[:len(filename)-5]
|
||||
desc, err := GetDescription(name)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
log.Printf("Reading group %v: %v", name, err)
|
||||
}
|
||||
continue
|
||||
log.Printf("Group file %v: %v", path, err)
|
||||
return nil
|
||||
}
|
||||
if desc.Public {
|
||||
Add(name, desc)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Couldn't read groups: %v", err);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue