fix(storage): do not write updated servers to file if file path is empty

This commit is contained in:
Quentin McGaw
2025-11-18 13:28:03 +00:00
parent 41cd8fb30d
commit 9963e18a8a

View File

@@ -21,6 +21,9 @@ func (s *Storage) FlushToFile(path string) error {
// flushToFile flushes the merged servers data to the file // flushToFile flushes the merged servers data to the file
// specified by path, as indented JSON. It is not thread-safe. // specified by path, as indented JSON. It is not thread-safe.
func (s *Storage) flushToFile(path string) error { func (s *Storage) flushToFile(path string) error {
if path == "" {
return nil // no file to write to
}
const permission = 0o644 const permission = 0o644
dirPath := filepath.Dir(path) dirPath := filepath.Dir(path)
if err := os.MkdirAll(dirPath, permission); err != nil { if err := os.MkdirAll(dirPath, permission); err != nil {