Backend: Add fix for concurrent cleanups to convert_sidecar_json.go

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-09-19 07:06:33 +02:00
parent 29ca2c1331
commit 41da164469

View File

@@ -65,9 +65,16 @@ func (w *Convert) ToJson(f *MediaFile, force bool) (jsonName string, err error)
}
}
// Write output to file.
// Write output to file (make parent dir robustly in case a parallel test cleaned the cache).
if err = os.WriteFile(jsonName, []byte(out.String()), fs.ModeFile); err != nil {
return "", err
// If the parent directory vanished due to concurrent cleanup, recreate and retry once.
if !os.IsNotExist(err) {
return "", err
} else if err = fs.MkdirAll(filepath.Dir(jsonName)); err != nil {
return "", err
} else if err = os.WriteFile(jsonName, []byte(out.String()), fs.ModeFile); err != nil {
return "", err
}
}
// Check if file exists.