Batch Edit: Add mutex.BatchEdit to prevent concurrent edits #271

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-11-23 09:38:34 +01:00
parent 7fbc0897c3
commit 6fabd096ee
5 changed files with 82 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
package api
import (
"errors"
"net/http"
"github.com/dustin/go-humanize/english"
@@ -92,7 +93,12 @@ func BatchPhotosEdit(router *gin.RouterGroup) {
if frm.Values != nil {
outcome, saveErr := batch.PrepareAndSavePhotos(photos, preloadedPhotos, frm.Values)
if saveErr != nil {
switch {
case errors.Is(saveErr, batch.ErrBatchEditBusy), errors.Is(saveErr, batch.ErrBatchEditCanceled):
log.Warnf("batch: %s", saveErr)
AbortBusy(c)
return
case saveErr != nil:
log.Errorf("batch: failed to persist photo updates: %s", saveErr)
AbortUnexpectedError(c)
return