1
Fork 0
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:
Juliusz Chroboczek 2021-01-13 22:56:43 +01:00
parent 82827453f0
commit 61990ff1ef

View file

@ -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);
}
}