Indexer: Use mutex when saving photos to avoid concurrency issues

This commit is contained in:
Michael Mayer 2020-12-14 20:56:33 +01:00
parent c2e5663da0
commit 387452858e

View file

@ -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") {