Labels: Fix saving categories in UpdateClassify()

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2022-04-04 00:57:13 +02:00
parent 686f6bc47c
commit cbcfa63f5f

View file

@ -197,16 +197,15 @@ func (m *Label) UpdateClassify(label classify.Label) error {
save = true
}
if !save {
return nil
}
// Save label.
if save {
if err := db.Save(m).Error; err != nil {
return err
}
}
// Update label categories.
if len(label.Categories) > 0 {
labelCategoriesMutex.Lock()
defer labelCategoriesMutex.Unlock()
@ -222,7 +221,8 @@ func (m *Label) UpdateClassify(label classify.Label) error {
}
if err := db.Model(m).Association("LabelCategories").Append(sn).Error; err != nil {
log.Warnf("index: failed saving label category %s (%s)", sanitize.Log(category), err)
log.Debugf("index: failed saving label category %s (%s)", sanitize.Log(category), err)
}
}
}