From 0bb5a6b57b308c1bd7463e767c6b0dc05acf7571 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 24 Jul 2023 19:59:05 +0300 Subject: disk file to be deleted when an event containing it is being removed --- plugins/Dbx_sqlite/src/dbevents.cpp | 3 ++- src/mir_app/src/file.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index 70f3a6e740..73baf8389c 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -220,6 +220,8 @@ BOOL CDbxSQLite::DeleteEvent(MEVENT hDbEvent) if (cc == nullptr) return 1; + NotifyEventHooks(g_hevEventDeleted, hContact, hDbEvent); + mir_cslockfull lock(m_csDbAccess); int rc = DeleteEventMain(hDbEvent); if (rc != SQLITE_DONE) @@ -237,7 +239,6 @@ BOOL CDbxSQLite::DeleteEvent(MEVENT hDbEvent) lock.unlock(); DBFlush(); - NotifyEventHooks(g_hevEventDeleted, hContact, hDbEvent); return 0; } diff --git a/src/mir_app/src/file.cpp b/src/mir_app/src/file.cpp index 97a6507a96..deaa693b8c 100644 --- a/src/mir_app/src/file.cpp +++ b/src/mir_app/src/file.cpp @@ -175,6 +175,18 @@ static int SRFilePreShutdown(WPARAM, LPARAM) return 0; } +static int SRFileEventDeleted(WPARAM /*hContact*/, LPARAM hDbEvent) +{ + DB::EventInfo dbei(hDbEvent); + if (dbei && dbei.eventType == EVENTTYPE_FILE) { + DB::FILE_BLOB blob(dbei); + if (auto *pwszName = blob.getLocalName()) + DeleteFileW(pwszName); + } + + return 0; +} + INT_PTR FtMgrShowCommand(WPARAM, LPARAM) { FtMgr_Show(true, true); @@ -314,6 +326,7 @@ int LoadSendRecvFileModule(void) HookEvent(ME_SYSTEM_MODULESLOADED, SRFileModulesLoaded); HookEvent(ME_SYSTEM_PRESHUTDOWN, SRFilePreShutdown); HookEvent(ME_OPT_INITIALISE, SRFileOptInitialise); + HookEvent(ME_DB_EVENT_DELETED, SRFileEventDeleted); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SRFilePreBuildMenu); HookEvent(ME_PROTO_ACK, SRFileProtoAck); -- cgit v1.2.3