🐛 Fix analyzer did not clear cache

This commit is contained in:
LittleSheep 2025-04-05 11:38:12 +08:00
parent 11d54c7c78
commit 048535d1c0
4 changed files with 12 additions and 12 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/keys /keys
.DS_Store .DS_Store
.idea

View File

@ -61,8 +61,9 @@ type Attachment struct {
Compressed *Attachment `json:"compressed"` Compressed *Attachment `json:"compressed"`
CompressedID *uint `json:"compressed_id"` CompressedID *uint `json:"compressed_id"`
Ref *Attachment `json:"ref"` Ref *Attachment `json:"ref"`
RefID *uint `json:"ref_id"` RefID *uint `json:"ref_id"`
RefURL *string `json:"ref_url"` // External URL for the attachment
Pool *AttachmentPool `json:"pool"` Pool *AttachmentPool `json:"pool"`
PoolID *uint `json:"pool_id"` PoolID *uint `json:"pool_id"`
@ -71,15 +72,13 @@ type Attachment struct {
AccountID uint `json:"account_id"` AccountID uint `json:"account_id"`
Account models.Account `gorm:"-" json:"account"` Account models.Account `gorm:"-" json:"account"`
// Outdated fields, just for backward compatibility
FileChunks datatypes.JSONMap `json:"file_chunks" gorm:"-"`
IsUploaded bool `json:"is_uploaded" gorm:"-"`
IsMature bool `json:"is_mature" gorm:"-"`
} }
func (v *Attachment) AfterUpdate(tx *gorm.DB) error { func (v *Attachment) AfterUpdate(tx *gorm.DB) error {
cachekit.FKey(cachekit.DAAttachment, v.Rid) _ = cachekit.Delete(
gap.Ca,
cachekit.FKey(cachekit.DAAttachment, v.Rid),
)
return nil return nil
} }
@ -114,7 +113,7 @@ type AttachmentFragment struct {
} }
func (v *AttachmentFragment) AfterUpdate(tx *gorm.DB) error { func (v *AttachmentFragment) AfterUpdate(tx *gorm.DB) error {
cachekit.Delete( _ = cachekit.Delete(
gap.Ca, gap.Ca,
cachekit.FKey("attachment-fragment", v.Rid), cachekit.FKey("attachment-fragment", v.Rid),
) )
@ -122,7 +121,7 @@ func (v *AttachmentFragment) AfterUpdate(tx *gorm.DB) error {
return nil return nil
} }
func (v AttachmentFragment) ToAttachment() Attachment { func (v *AttachmentFragment) ToAttachment() Attachment {
return Attachment{ return Attachment{
Rid: v.Rid, Rid: v.Rid,
Uuid: v.Uuid, Uuid: v.Uuid,

View File

@ -6,8 +6,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
"git.solsynth.dev/hypernet/paperclip/pkg/filekit/models" "git.solsynth.dev/hypernet/paperclip/pkg/filekit/models"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
"github.com/spf13/viper" "github.com/spf13/viper"
) )

View File

@ -16,9 +16,9 @@ import (
"github.com/barasher/go-exiftool" "github.com/barasher/go-exiftool"
"github.com/samber/lo" "github.com/samber/lo"
"git.solsynth.dev/hypernet/paperclip/pkg/filekit/models"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database" "git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/fs" "git.solsynth.dev/hypernet/paperclip/pkg/internal/fs"
"git.solsynth.dev/hypernet/paperclip/pkg/filekit/models"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"github.com/k0kubun/go-ansi" "github.com/k0kubun/go-ansi"
"github.com/kettek/apng" "github.com/kettek/apng"