summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-24 19:59:05 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-24 19:59:05 +0300
commit0bb5a6b57b308c1bd7463e767c6b0dc05acf7571 (patch)
tree452ab2a50b2893dffaad27c333dbd3780565d40c
parent96ac0b0639e1c6396cb084349f9361a1c34ddb57 (diff)
disk file to be deleted when an event containing it is being removed
-rw-r--r--plugins/Dbx_sqlite/src/dbevents.cpp3
-rw-r--r--src/mir_app/src/file.cpp13
2 files changed, 15 insertions, 1 deletions
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);