From 387452858e089bb49f8849dd80776e6a42a684c5 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 14 Dec 2020 20:56:33 +0100 Subject: [PATCH] Indexer: Use mutex when saving photos to avoid concurrency issues --- internal/entity/photo.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/entity/photo.go b/internal/entity/photo.go index b5698d3b9..8edc43606 100644 --- a/internal/entity/photo.go +++ b/internal/entity/photo.go @@ -227,6 +227,9 @@ func (m *Photo) Create() error { // Save updates an existing photo or inserts a new one. func (m *Photo) Save() error { + photoMutex.Lock() + defer photoMutex.Unlock() + if err := UnscopedDb().Save(m).Error; err == nil { // Nothing to do. } else if !strings.Contains(strings.ToLower(err.Error()), "lock") {