From 0e0ad9c261144e7012104ee7e55ec34ab7e4c839 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 29 Dec 2024 01:58:26 +0800 Subject: [PATCH] :bug: Fix more older cache issue --- pkg/internal/models/attachments.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/internal/models/attachments.go b/pkg/internal/models/attachments.go index 23fee8b..8a5aa3b 100644 --- a/pkg/internal/models/attachments.go +++ b/pkg/internal/models/attachments.go @@ -86,6 +86,10 @@ func (v *Attachment) AfterUpdate(tx *gorm.DB) error { ctx, fmt.Sprintf("attachment#%s", v.Rid), ) + _ = marshal.Delete( + ctx, + fmt.Sprintf("attachment-open#%s", v.Rid), + ) return nil } @@ -119,6 +123,19 @@ type AttachmentFragment struct { FileChunksMissing []string `json:"file_chunks_missing" gorm:"-"` // This field use to prompt client which chunks is pending upload, do not store it } +func (v *AttachmentFragment) AfterUpdate(tx *gorm.DB) error { + cacheManager := cache.New[any](localCache.S) + marshal := marshaler.New(cacheManager) + ctx := context.Background() + + _ = marshal.Delete( + ctx, + fmt.Sprintf("attachment-fragment#%s", v.Rid), + ) + + return nil +} + func (v AttachmentFragment) ToAttachment() Attachment { return Attachment{ Rid: v.Rid,