summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-01-31 22:35:54 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-01-31 22:35:54 +0300
commit36d0c8d1d781d80e4bee71208d72ea5a1f8e1fec (patch)
tree30aa8f85dda26de517982e3b5c3e6c6d3d18056a
parentc6b493f65d7d768782852b6379c663161b63695f (diff)
we import slower, but more securely (flush database time to time)
-rw-r--r--include/m_db_int.h5
-rw-r--r--libs/win32/mir_app.libbin218472 -> 218748 bytes
-rw-r--r--libs/win64/mir_app.libbin214280 -> 214560 bytes
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.cpp8
-rw-r--r--plugins/Dbx_mdbx/src/dbintf.h5
-rwxr-xr-xplugins/Dbx_sqlite/src/dbintf.cpp14
-rwxr-xr-xplugins/Dbx_sqlite/src/dbintf.h1
-rw-r--r--plugins/Import/src/import.cpp6
-rw-r--r--src/mir_app/src/MDatabaseCommon.cpp5
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
11 files changed, 41 insertions, 5 deletions
diff --git a/include/m_db_int.h b/include/m_db_int.h
index 198f21a030..71adc82826 100644
--- a/include/m_db_int.h
+++ b/include/m_db_int.h
@@ -155,11 +155,11 @@ interface MIR_APP_EXPORT MIDatabase
STDMETHOD_(BOOL, Compact)(void) PURE;
STDMETHOD_(BOOL, Backup)(LPCWSTR) PURE;
-
+ STDMETHOD_(BOOL, Flush)(void) PURE;
+
STDMETHOD_(MIDatabaseChecker*, GetChecker)(void) PURE;
STDMETHOD_(DATABASELINK*, GetDriver)(void) PURE;
-
STDMETHOD_(MEVENT, GetEventById)(LPCSTR szModule, LPCSTR szId) PURE;
STDMETHOD_(DB::EventCursor*, EventCursor)(MCONTACT hContact, MEVENT hDbEvent) PURE;
@@ -228,6 +228,7 @@ public:
STDMETHODIMP_(BOOL) Compact(void) override;
STDMETHODIMP_(BOOL) Backup(LPCWSTR) override;
+ STDMETHODIMP_(BOOL) Flush(void) override;
STDMETHODIMP_(MIDatabaseChecker*) GetChecker(void) override;
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 613bba09d5..cb9e0f8b74 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index ca54bbc718..aad0cf2b19 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp
index bb46a1ddb6..5fbfdf1f69 100644
--- a/plugins/Dbx_mdbx/src/dbintf.cpp
+++ b/plugins/Dbx_mdbx/src/dbintf.cpp
@@ -228,6 +228,14 @@ int CDbxMDBX::Load()
/////////////////////////////////////////////////////////////////////////////////////////
+BOOL CDbxMDBX::Flush()
+{
+ DBFlush(true);
+ return ERROR_SUCCESS;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static void assert_func(const MDBX_env*, const char *msg, const char *function, unsigned line) MDBX_CXX17_NOEXCEPT
{
Netlib_Logf(nullptr, "MDBX: assertion failed (%s, %d): %s", function, line, msg);
diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h
index 02f4ad8689..4b6aac5804 100644
--- a/plugins/Dbx_mdbx/src/dbintf.h
+++ b/plugins/Dbx_mdbx/src/dbintf.h
@@ -279,8 +279,9 @@ public:
STDMETHODIMP_(BOOL) ReadCryptoKey(MBinBuffer&) override;
STDMETHODIMP_(BOOL) StoreCryptoKey(void) override;
- STDMETHODIMP_(BOOL) Compact();
- STDMETHODIMP_(BOOL) Backup(const wchar_t*);
+ STDMETHODIMP_(BOOL) Compact() override;
+ STDMETHODIMP_(BOOL) Backup(const wchar_t*) override;
+ STDMETHODIMP_(BOOL) Flush() override;
STDMETHODIMP_(MEVENT) GetEventById(const char *szModule, const char *szId) override;
diff --git a/plugins/Dbx_sqlite/src/dbintf.cpp b/plugins/Dbx_sqlite/src/dbintf.cpp
index 474aaad4a5..9e6cbeb6bb 100755
--- a/plugins/Dbx_sqlite/src/dbintf.cpp
+++ b/plugins/Dbx_sqlite/src/dbintf.cpp
@@ -25,6 +25,8 @@ CDbxSQLite::~CDbxSQLite()
}
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int CDbxSQLite::Create(const wchar_t *profile)
{
sqlite3 *database = nullptr;
@@ -64,6 +66,8 @@ int CDbxSQLite::Create(const wchar_t *profile)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
int CDbxSQLite::Check(const wchar_t *profile)
{
FILE *hFile = _wfopen(profile, L"rb");
@@ -96,6 +100,8 @@ int CDbxSQLite::Check(const wchar_t *profile)
return EGROKPRF_NOERROR;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MDatabaseCommon* CDbxSQLite::Load(const wchar_t *profile, int readonly)
{
sqlite3 *database = nullptr;
@@ -138,6 +144,8 @@ MDatabaseCommon* CDbxSQLite::Load(const wchar_t *profile, int readonly)
return db;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
BOOL CDbxSQLite::Backup(LPCWSTR profile)
{
sqlite3 *database = nullptr;
@@ -182,6 +190,12 @@ void CDbxSQLite::DBFlush(bool bForce)
m_impl.m_timer.Start(50);
}
+BOOL CDbxSQLite::Flush()
+{
+ DBFlush(true);
+ return ERROR_SUCCESS;
+}
+
BOOL CDbxSQLite::IsRelational()
{
return TRUE;
diff --git a/plugins/Dbx_sqlite/src/dbintf.h b/plugins/Dbx_sqlite/src/dbintf.h
index 98b8765195..9acbe25db9 100755
--- a/plugins/Dbx_sqlite/src/dbintf.h
+++ b/plugins/Dbx_sqlite/src/dbintf.h
@@ -129,6 +129,7 @@ public:
STDMETHODIMP_(BOOL) Compact() override;
STDMETHODIMP_(BOOL) Backup(LPCWSTR) override;
+ STDMETHODIMP_(BOOL) Flush() override;
STDMETHODIMP_(DATABASELINK*) GetDriver() override;
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index 68b927a66f..183152c98f 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -548,7 +548,6 @@ int CImportBatch::ImportGroups()
Clist_GroupSetExpanded(group_id, (it->wszName[0] & GROUPF_EXPANDED));
}
-
return arGroups.getCount();
}
@@ -1051,6 +1050,7 @@ void CImportBatch::DoImport()
AddMessage(L"");
}
+ dstDb->Flush();
// End of Import Groups
// Import Contacts
@@ -1081,6 +1081,7 @@ void CImportBatch::DoImport()
}
else AddMessage(LPGENW("Skipping new contacts import."));
AddMessage(L"");
+ dstDb->Flush();
// End of Import Contacts
// Import NULL contact message chain
@@ -1096,6 +1097,7 @@ void CImportBatch::DoImport()
}
else AddMessage(LPGENW("Skipping system history import."));
AddMessage(L"");
+ dstDb->Flush();
// Import other contact messages
if (m_iOptions & IOPT_HISTORY) {
@@ -1103,6 +1105,7 @@ void CImportBatch::DoImport()
MCONTACT hContact = srcDb->FindFirstContact();
for (int i = 1; hContact != NULL; i++) {
ImportHistory(hContact, nullptr, NULL);
+ dstDb->Flush();
SetProgress(100 * i / nNumberOfContacts);
hContact = srcDb->FindNextContact(hContact);
@@ -1110,6 +1113,7 @@ void CImportBatch::DoImport()
}
else AddMessage(LPGENW("Skipping history import."));
AddMessage(L"");
+ dstDb->Flush();
// Restore database writing mode
dstDb->SetCacheSafetyMode(TRUE);
diff --git a/src/mir_app/src/MDatabaseCommon.cpp b/src/mir_app/src/MDatabaseCommon.cpp
index 590e6f8dce..5133a55b91 100644
--- a/src/mir_app/src/MDatabaseCommon.cpp
+++ b/src/mir_app/src/MDatabaseCommon.cpp
@@ -149,6 +149,11 @@ BOOL MDatabaseCommon::Backup(LPCWSTR)
return ERROR_NOT_SUPPORTED;
}
+BOOL MDatabaseCommon::Flush(void)
+{
+ return ERROR_NOT_SUPPORTED;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// Contacts
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 58619f5392..61a832b972 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -771,3 +771,4 @@ _Netlib_GetTlsUnique@8 @831 NONAME
?EnableEncryption@MDatabaseReadonly@@UAGHH@Z @859 NONAME
?Tray1Click@Clist@@3V?$CMOption@_N@@A @860 NONAME
?TrayAlwaysStatus@Clist@@3V?$CMOption@_N@@A @861 NONAME
+?Flush@MDatabaseCommon@@UAGHXZ @862 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 0b45f3ea01..b0b9a06846 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -771,3 +771,4 @@ Netlib_GetTlsUnique @831 NONAME
?EnableEncryption@MDatabaseReadonly@@UEAAHH@Z @859 NONAME
?Tray1Click@Clist@@3V?$CMOption@_N@@A @860 NONAME
?TrayAlwaysStatus@Clist@@3V?$CMOption@_N@@A @861 NONAME
+?Flush@MDatabaseCommon@@UEAAHXZ @862 NONAME