diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-21 17:47:28 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-21 17:47:28 +0000 |
commit | 00a8ec3be1ebc0367e6725f93833bd53323ffae5 (patch) | |
tree | 1eebc55aaa1ae5374afe791a082056bfa999141f /plugins/DbChecker | |
parent | 099decfc4c419bb0b12a2b1c4c285c0ef1568430 (diff) |
fix for running dbchecker over the locked profile
git-svn-id: http://svn.miranda-ng.org/main/trunk@8673 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/DbChecker')
-rw-r--r-- | plugins/DbChecker/src/selectdb.cpp | 25 | ||||
-rw-r--r-- | plugins/DbChecker/src/version.h | 16 |
2 files changed, 29 insertions, 12 deletions
diff --git a/plugins/DbChecker/src/selectdb.cpp b/plugins/DbChecker/src/selectdb.cpp index a92d72febc..32f2370077 100644 --- a/plugins/DbChecker/src/selectdb.cpp +++ b/plugins/DbChecker/src/selectdb.cpp @@ -18,6 +18,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "dbchecker.h"
+static bool CheckBroken(const TCHAR *ptszFullPath)
+{
+ DATABASELINK *dblink = FindDatabasePlugin(ptszFullPath);
+ if (dblink == NULL || dblink->CheckDB == NULL)
+ return true;
+
+ int error = 0;
+ MIDatabaseChecker *dbChecker = dblink->CheckDB(ptszFullPath, &error);
+ if (dbChecker == NULL)
+ return true;
+
+ dbChecker->Destroy();
+ return false;
+}
+
void OpenDatabase(HWND hdlg, INT iNextPage)
{
TCHAR tszMsg[1024];
@@ -43,7 +58,8 @@ LBL_Error: int error = 0;
opts.dbChecker = dblink->CheckDB(opts.filename, &error);
if (opts.dbChecker == NULL) {
- opts.error = error;
+ if ((opts.error = GetLastError()) == 0)
+ opts.error = error;
PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, (LPARAM)OpenErrorDlgProc);
return;
}
@@ -86,10 +102,11 @@ static int AddDatabaseToList(HWND hwndList, const TCHAR* filename, TCHAR* dir) if ( _tstat(filename, &st) == -1)
return -1;
- int broken = 0;
DWORD totalSize = st.st_size;
DWORD wasted = 0;
+ bool isBroken = CheckBroken(filename);
+
const TCHAR *pName = _tcsrchr(filename, '\\');
if (pName == NULL)
pName = (LPTSTR)filename;
@@ -108,7 +125,7 @@ static int AddDatabaseToList(HWND hwndList, const TCHAR* filename, TCHAR* dir) lvi.iSubItem = 0;
lvi.lParam = (LPARAM)_tcsdup(filename);
lvi.pszText = szName;
- if (broken)
+ if (isBroken)
lvi.iImage = 3;
else if (wasted < 1024*128)
lvi.iImage = 0;
@@ -121,7 +138,7 @@ static int AddDatabaseToList(HWND hwndList, const TCHAR* filename, TCHAR* dir) TCHAR szSize[20];
mir_sntprintf(szSize, SIZEOF(szSize), _T("%.2lf MB"), totalSize / 1048576.0);
ListView_SetItemText(hwndList, iNewItem, 1, szSize);
- if (!broken) {
+ if (!isBroken) {
mir_sntprintf(szSize, SIZEOF(szSize), _T("%.2lf MB"), wasted / 1048576.0);
ListView_SetItemText(hwndList, iNewItem, 2, szSize);
}
diff --git a/plugins/DbChecker/src/version.h b/plugins/DbChecker/src/version.h index 5282ad490a..911e6fc2fa 100644 --- a/plugins/DbChecker/src/version.h +++ b/plugins/DbChecker/src/version.h @@ -1,14 +1,14 @@ -#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 11
-#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 95
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 2
#include <stdver.h>
#define __PLUGIN_NAME "Database checker"
#define __FILENAME "DbChecker.dll"
-#define __DESCRIPTION "Miranda NG Database Checker."
-#define __AUTHOR "George Hazan"
+#define __DESCRIPTION "Miranda NG Database Checker."
+#define __AUTHOR "George Hazan"
#define __AUTHOREMAIL "ghazan@miranda-ng.org"
-#define __AUTHORWEB "http://miranda-ng.org/p/DbChecker/"
-#define __COPYRIGHT "© 2012 George Hazan"
+#define __AUTHORWEB "http://miranda-ng.org/p/DbChecker/"
+#define __COPYRIGHT "© 2012-14 George Hazan"
|