From 1e2176029a94fd8c8e404e4d6b969abef08be40f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 13 Jan 2020 14:10:49 +0300 Subject: fixes #2181 ("Miranda was unable to open , it's in an unknown format") --- plugins/Dbx_mdbx/src/dbintf.cpp | 9 +++++++++ plugins/Dbx_mdbx/src/dbintf.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp index db87bcca74..07307cd22a 100644 --- a/plugins/Dbx_mdbx/src/dbintf.cpp +++ b/plugins/Dbx_mdbx/src/dbintf.cpp @@ -60,6 +60,15 @@ int CDbxMDBX::Load() unsigned int defFlags = MDBX_CREATE; { txn_ptr trnlck(StartTran()); + if (trnlck == nullptr) { + if (m_dbError == MDBX_TXN_FULL) { + if (IDOK == MessageBox(NULL, TranslateT("Your database is in the obsolete format. Click Ok to read the upgrade instructions or Cancel to exit"), TranslateT("Error"), MB_ICONERROR | MB_OKCANCEL)) + Utils_OpenUrl("https://www.miranda-ng.org/news/unknown_profile_format"); + return EGROKPRF_OBSOLETE; + } + return EGROKPRF_DAMAGED; + } + mdbx_dbi_open(trnlck, "global", defFlags | MDBX_INTEGERKEY, &m_dbGlobal); mdbx_dbi_open(trnlck, "crypto", defFlags, &m_dbCrypto); mdbx_dbi_open(trnlck, "contacts", defFlags | MDBX_INTEGERKEY, &m_dbContacts); diff --git a/plugins/Dbx_mdbx/src/dbintf.h b/plugins/Dbx_mdbx/src/dbintf.h index acba02260d..53d598b406 100644 --- a/plugins/Dbx_mdbx/src/dbintf.h +++ b/plugins/Dbx_mdbx/src/dbintf.h @@ -158,13 +158,12 @@ class CDbxMDBX : public MDatabaseCommon, public MZeroedObject } } m_impl; - __forceinline MDBX_txn* StartTran() const + __forceinline MDBX_txn* StartTran() { MDBX_txn *res = 0; - int rc = mdbx_txn_begin(m_env, nullptr, (m_bReadOnly) ? MDBX_RDONLY : 0, &res); + m_dbError = mdbx_txn_begin(m_env, nullptr, (m_bReadOnly) ? MDBX_RDONLY : 0, &res); /* FIXME: throw an exception */ - _ASSERT(rc == MDBX_SUCCESS); - UNREFERENCED_PARAMETER(rc); + _ASSERT(m_dbError == MDBX_SUCCESS); return res; } @@ -181,8 +180,9 @@ class CDbxMDBX : public MDatabaseCommon, public MZeroedObject TCHAR* m_tszProfileName; bool m_safetyMode, m_bReadOnly, m_bShared, m_bEncrypted, m_bUsesPassword; - MDBX_env *m_env; + MDBX_env *m_env; CMDBX_txn_ro m_txn_ro; + int m_dbError; MDBX_dbi m_dbGlobal; DBHeader m_header; @@ -192,7 +192,7 @@ class CDbxMDBX : public MDatabaseCommon, public MZeroedObject //////////////////////////////////////////////////////////////////////////// // settings - MDBX_dbi m_dbSettings; + MDBX_dbi m_dbSettings; MDBX_cursor *m_curSettings; HANDLE hService[2], hHook; @@ -219,7 +219,7 @@ class CDbxMDBX : public MDatabaseCommon, public MZeroedObject //////////////////////////////////////////////////////////////////////////// // modules - MDBX_dbi m_dbModules; + MDBX_dbi m_dbModules; MDBX_cursor *m_curModules; std::map m_Modules; @@ -232,7 +232,7 @@ class CDbxMDBX : public MDatabaseCommon, public MZeroedObject //////////////////////////////////////////////////////////////////////////// // encryption - MDBX_dbi m_dbCrypto; + MDBX_dbi m_dbCrypto; int InitCrypt(void); CRYPTO_PROVIDER* SelectProvider(); -- cgit v1.2.3