Change update attachment policy to prevent conflict with analyzer

This commit is contained in:
LittleSheep 2024-07-29 21:11:42 +08:00
parent 36c814e1dc
commit 8196aac3de
2 changed files with 4 additions and 6 deletions

View File

@ -142,7 +142,6 @@ func updateAttachmentMeta(c *fiber.Ctx) error {
var data struct { var data struct {
Alternative string `json:"alt"` Alternative string `json:"alt"`
Usage string `json:"usage"` Usage string `json:"usage"`
Metadata map[string]any `json:"metadata"`
IsMature bool `json:"is_mature"` IsMature bool `json:"is_mature"`
} }
@ -157,7 +156,6 @@ func updateAttachmentMeta(c *fiber.Ctx) error {
attachment.Alternative = data.Alternative attachment.Alternative = data.Alternative
attachment.Usage = data.Usage attachment.Usage = data.Usage
attachment.Metadata = data.Metadata
attachment.IsMature = data.IsMature attachment.IsMature = data.IsMature
if attachment, err := services.UpdateAttachment(attachment); err != nil { if attachment, err := services.UpdateAttachment(attachment); err != nil {

View File

@ -113,7 +113,7 @@ func TryLinkAttachment(tx *gorm.DB, og models.Attachment, hash string) (bool, er
} }
func UpdateAttachment(item models.Attachment) (models.Attachment, error) { func UpdateAttachment(item models.Attachment) (models.Attachment, error) {
if err := database.C.Save(&item).Error; err != nil { if err := database.C.Updates(&item).Error; err != nil {
return item, err return item, err
} else { } else {
MaintainAttachmentCache() MaintainAttachmentCache()