From 3715d53db7ea0b295331bcc58c5e71899ed81a41 Mon Sep 17 00:00:00 2001 From: Sydonian <794346190@qq.com> Date: Wed, 24 May 2023 16:05:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0StorageObject=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E6=8A=95=E9=80=92CheckObject=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/event/check_object.go | 3 +-- internal/event/update_storage.go | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/event/check_object.go b/internal/event/check_object.go index b969a1d..e8a5163 100644 --- a/internal/event/check_object.go +++ b/internal/event/check_object.go @@ -3,7 +3,6 @@ package event import ( "github.com/samber/lo" "gitlink.org.cn/cloudream/common/utils/logger" - mysql "gitlink.org.cn/cloudream/db/sql" scevt "gitlink.org.cn/cloudream/rabbitmq/message/scanner/event" ) @@ -29,7 +28,7 @@ func (t *CheckObject) TryMerge(other Event) bool { func (t *CheckObject) Execute(execCtx ExecuteContext) { for _, objID := range t.ObjectIDs { - err := mysql.Object.DeleteUnused(execCtx.Args.DB.SQLCtx(), objID) + err := execCtx.Args.DB.Object().DeleteUnused(execCtx.Args.DB.SQLCtx(), objID) if err != nil { logger.WithField("ObjectID", objID).Warnf("delete unused object failed, err: %s", err.Error()) } diff --git a/internal/event/update_storage.go b/internal/event/update_storage.go index e54c65d..ad8f393 100644 --- a/internal/event/update_storage.go +++ b/internal/event/update_storage.go @@ -41,6 +41,7 @@ func (t *UpdateStorage) Execute(execCtx ExecuteContext) { logger.WithField("StorageID", t.StorageID).Warnf("change storage state failed, err: %s", err.Error()) } + var chkObjIDs []int for _, entry := range t.Entries { switch entry.Operation { case tskcst.UPDATE_STORAGE_DELETE: @@ -50,6 +51,7 @@ func (t *UpdateStorage) Execute(execCtx ExecuteContext) { WithField("ObjectID", entry.ObjectID). Warnf("delete storage object failed, err: %s", err.Error()) } + chkObjIDs = append(chkObjIDs, entry.ObjectID) case tskcst.UPDATE_STORAGE_SET_NORMAL: err := mysql.StorageObject.SetStateNormal(execCtx.Args.DB.SQLCtx(), t.StorageID, entry.ObjectID, entry.UserID) @@ -60,6 +62,10 @@ func (t *UpdateStorage) Execute(execCtx ExecuteContext) { } } } + + if len(chkObjIDs) > 0 { + execCtx.Executor.Post(NewCheckObject(chkObjIDs)) + } } func init() {