feat: prefer util.WritablePath() for logs and local storage

This commit is contained in:
hkfires
2025-10-19 10:19:55 +08:00
parent 674393ec12
commit d16599fa1d
6 changed files with 57 additions and 8 deletions

View File

@@ -84,3 +84,17 @@ func CountAuthFiles(authDir string) int {
}
return count
}
// WritablePath returns the cleaned WRITABLE_PATH environment variable when it is set.
// It accepts both uppercase and lowercase variants for compatibility with existing conventions.
func WritablePath() string {
for _, key := range []string{"WRITABLE_PATH", "writable_path"} {
if value, ok := os.LookupEnv(key); ok {
trimmed := strings.TrimSpace(value)
if trimmed != "" {
return filepath.Clean(trimmed)
}
}
}
return ""
}