diff options
author | George Hazan <ghazan@miranda.im> | 2021-01-31 22:35:54 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-01-31 22:35:54 +0300 |
commit | 36d0c8d1d781d80e4bee71208d72ea5a1f8e1fec (patch) | |
tree | 30aa8f85dda26de517982e3b5c3e6c6d3d18056a /plugins | |
parent | c6b493f65d7d768782852b6379c663161b63695f (diff) |
we import slower, but more securely (flush database time to time)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.cpp | 8 | ||||
-rw-r--r-- | plugins/Dbx_mdbx/src/dbintf.h | 5 | ||||
-rwxr-xr-x | plugins/Dbx_sqlite/src/dbintf.cpp | 14 | ||||
-rwxr-xr-x | plugins/Dbx_sqlite/src/dbintf.h | 1 | ||||
-rw-r--r-- | plugins/Import/src/import.cpp | 6 |
5 files changed, 31 insertions, 3 deletions
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);
|