🐛 Bug fixes and optimization

This commit is contained in:
2024-08-20 22:55:58 +08:00
parent 37c47f9839
commit 7a8fa116d3
5 changed files with 59 additions and 36 deletions

View File

@@ -53,7 +53,10 @@ func ScanUnanalyzedFileFromDatabase() {
}
var attachments []models.Attachment
if err := database.C.Where("destination = ? OR is_analyzed = ?", models.AttachmentDstTemporary, false).Find(&attachments).Error; err != nil {
if err := database.C.
Where("is_uploaded = ?", true).
Where("destination = ? OR is_analyzed = ?", models.AttachmentDstTemporary, false).
Find(&attachments).Error; err != nil {
log.Error().Err(err).Msg("Scan unanalyzed files from database failed...")
return
}
@@ -93,7 +96,9 @@ func ScanUnanalyzedFileFromDatabase() {
}
func AnalyzeAttachment(file models.Attachment) error {
if file.Destination != models.AttachmentDstTemporary {
if !file.IsUploaded {
return fmt.Errorf("file isn't finish multipart upload")
} else if file.Destination != models.AttachmentDstTemporary {
return fmt.Errorf("attachment isn't in temporary storage, unable to analyze")
}