From b2c47fe47b18d21b90d9c536e70bf45ef9d33e3c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 26 Mar 2018 00:01:31 +0300 Subject: fixes #1208 (if profile is opened in r/w mode, it should be locked) --- plugins/Dbx_mdbx/src/dbintf.cpp | 4 +++- src/mir_app/src/database.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/Dbx_mdbx/src/dbintf.cpp b/plugins/Dbx_mdbx/src/dbintf.cpp index 5ecac705be..ee0c7b8e3c 100644 --- a/plugins/Dbx_mdbx/src/dbintf.cpp +++ b/plugins/Dbx_mdbx/src/dbintf.cpp @@ -194,5 +194,7 @@ int CDbxMDBX::Map() unsigned int mode = MDBX_NOSUBDIR | MDBX_MAPASYNC | MDBX_WRITEMAP | MDBX_NOSYNC; if (m_bReadOnly) mode |= MDBX_RDONLY; - return mdbx_env_open(m_env, _T2A(m_tszProfileName), mode, 0664); + + int exclusive = (m_bShared) ? 1 : 2; + return mdbx_env_open_ex(m_env, _T2A(m_tszProfileName), mode, 0664, &exclusive); } diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp index ce47bd9981..f0dbfa8077 100644 --- a/src/mir_app/src/database.cpp +++ b/src/mir_app/src/database.cpp @@ -505,19 +505,22 @@ int LoadDatabaseModule(void) } else if (rc > 0) { // if there were drivers but they all failed cos the file is locked, try and find the miranda which locked it + if (FindMirandaForProfile(szProfile)) + break; + if (fileExist(szProfile)) { // file isn't locked, just no driver could open it. MessageBox(nullptr, CMStringW(FORMAT, TranslateW(tszUnknownFormat), ptszFileName), TranslateT("Miranda can't understand that profile"), MB_OK | MB_ICONERROR); } - else if (!FindMirandaForProfile(szProfile)) { + else retry = IDRETRY == MessageBox(nullptr, CMStringW(FORMAT, TranslateW(tszProfileLocked), ptszFileName), TranslateT("Miranda can't open that profile"), MB_RETRYCANCEL | MB_ICONERROR); - } } - } while (retry); + } + while (retry); if (rc == ERROR_SUCCESS) { InitIni(); -- cgit v1.2.3