diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 34e7a53..6c129a3 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,10 @@
-
+
-
+
+
@@ -117,7 +118,6 @@
-
@@ -142,7 +142,8 @@
-
+
+
true
diff --git a/pkg/internal/services/attachments.go b/pkg/internal/services/attachments.go
index c3f2cac..a020205 100644
--- a/pkg/internal/services/attachments.go
+++ b/pkg/internal/services/attachments.go
@@ -31,7 +31,6 @@ func GetAttachmentByID(id uint) (models.Attachment, error) {
}).Preload("Pool").Preload("Account").First(&attachment).Error; err != nil {
return attachment, err
} else {
- MaintainAttachmentCache()
CacheAttachment(attachment)
}
@@ -49,7 +48,6 @@ func GetAttachmentByRID(rid string) (models.Attachment, error) {
}).Preload("Pool").Preload("Account").First(&attachment).Error; err != nil {
return attachment, err
} else {
- MaintainAttachmentCache()
CacheAttachment(attachment)
}
@@ -74,6 +72,7 @@ func GetAttachmentCache(id any) (models.Attachment, bool) {
}
func CacheAttachment(item models.Attachment) {
+ MaintainAttachmentCache()
metadataCache.Store(item.Rid, item)
}
@@ -110,7 +109,6 @@ func NewAttachmentMetadata(tx *gorm.DB, user models.Account, file *multipart.Fil
if err := tx.Save(&attachment).Error; err != nil {
return attachment, fmt.Errorf("failed to save attachment record: %v", err)
} else {
- MaintainAttachmentCache()
CacheAttachment(attachment)
}
@@ -142,7 +140,6 @@ func NewAttachmentPlaceholder(tx *gorm.DB, user models.Account, attachment model
if err := tx.Save(&attachment).Error; err != nil {
return attachment, fmt.Errorf("failed to save attachment record: %v", err)
} else {
- MaintainAttachmentCache()
CacheAttachment(attachment)
}
@@ -189,7 +186,6 @@ func UpdateAttachment(item models.Attachment) (models.Attachment, error) {
if err := database.C.Updates(&item).Error; err != nil {
return item, err
} else {
- MaintainAttachmentCache()
CacheAttachment(item)
}
diff --git a/pkg/internal/services/uploader.go b/pkg/internal/services/uploader.go
index bbbb8bf..1f9963a 100644
--- a/pkg/internal/services/uploader.go
+++ b/pkg/internal/services/uploader.go
@@ -113,7 +113,7 @@ func ReUploadFileToPermanent(meta models.Attachment) error {
}
database.C.Save(&meta)
- metadataCache.Store(meta.ID, meta)
+ CacheAttachment(meta)
return nil
case models.DestinationTypeS3:
var destConfigured models.S3Destination
@@ -137,7 +137,7 @@ func ReUploadFileToPermanent(meta models.Attachment) error {
}
database.C.Save(&meta)
- metadataCache.Store(meta.ID, meta)
+ CacheAttachment(meta)
return nil
default:
return fmt.Errorf("invalid destination: unsupported protocol %s", dest.Type)