♻️ Use update api instead of overhaul in background tasks

This commit is contained in:
2025-01-01 11:43:54 +08:00
parent 2bd8dc17d1
commit 5e73d9acd4
3 changed files with 12 additions and 18 deletions

View File

@@ -220,16 +220,14 @@ func AnalyzeAttachment(file models.Attachment) error {
tx := database.C.Begin()
file.IsAnalyzed = true
if err := tx.Model(&file).Update("is_analyzed", true).Error; err != nil {
tx.Rollback()
return fmt.Errorf("unable to update file record: %v", err)
}
linked, err := TryLinkAttachment(tx, file, file.HashCode)
if linked && err != nil {
return fmt.Errorf("unable to link file record: %v", err)
} else if !linked {
if err := tx.Save(&file).Error; err != nil {
tx.Rollback()
return fmt.Errorf("unable to save file record: %v", err)
}
}
tx.Commit()