grim/hgkeeper

Use Go 1.22 and update dependencies
default tip
2 months ago, aklitzing
f33f223bc8fe
Use Go 1.22 and update dependencies

Reviewed at https://reviews.imfreedom.org/r/2949/
package access
import (
"fmt"
"os"
"sort"
)
func refreshHgWeb() error {
fp, err := os.OpenFile(hgwebConfigPath, os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return err
}
defer fp.Close()
fmt.Fprintf(fp, "[paths]\n")
keys := make([]string, 0, len(repositories))
for k := range repositories {
keys = append(keys, k)
}
sort.Strings(keys)
for _, relativeRepoPath := range keys {
rootedPath := "/" + relativeRepoPath
// check if it's publicly readable
if CanRead("public", rootedPath) {
fmt.Fprintf(fp, "%s = %s\n", rootedPath, repositories[relativeRepoPath])
}
}
return nil
}