mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00
Backend: Add fix for concurrent cleanups to convert_sidecar_json.go
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user