diff options
author | George Hazan <george.hazan@gmail.com> | 2013-12-30 15:31:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-12-30 15:31:43 +0000 |
commit | b67369c7256dc40eb7aa7b3527c1cb45e2a27b27 (patch) | |
tree | c0dc8d4cf1c2b91fb5e7dbae61a9acddab458624 /src/modules/database/database.cpp | |
parent | c06d1b859bfae04cb96633a8d3f2d55194f84421 (diff) |
if a database driver already printed an error, there's no need to do that twice
git-svn-id: http://svn.miranda-ng.org/main/trunk@7431 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/database/database.cpp')
-rw-r--r-- | src/modules/database/database.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index 377ec31933..c3afff451f 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -340,35 +340,36 @@ char* makeFileName(const TCHAR* tszOriginalName) // enumerate all plugins that had valid DatabasePluginInfo()
int tryOpenDatabase(const TCHAR *tszProfile)
{
+ bool bWasOpened = false;
+
for (int i=arDbPlugins.getCount()-1; i >= 0; i--) {
DATABASELINK *p = arDbPlugins[i];
// liked the profile?
int err = p->grokHeader(tszProfile);
- if (err == ERROR_SUCCESS) {
- // added APIs?
- MIDatabase *pDb = p->Load(tszProfile);
- if (pDb) {
- fillProfileName(tszProfile);
- currDblink = p;
- db_setCurrent(currDb = pDb);
- return 0;
- }
- }
- else {
+ if (err != ERROR_SUCCESS) { // smth went wrong
switch (err) {
case EGROKPRF_CANTREAD:
case EGROKPRF_UNKHEADER:
// just not supported.
continue;
-
- case EGROKPRF_VERNEWER:
- case EGROKPRF_DAMAGED:
- return 1;
}
- } //if
+ return err;
+ }
+
+ bWasOpened = true;
+
+ // try to load database
+ MIDatabase *pDb = p->Load(tszProfile);
+ if (pDb) {
+ fillProfileName(tszProfile);
+ currDblink = p;
+ db_setCurrent(currDb = pDb);
+ return 0;
+ }
}
- return 1;
+
+ return (bWasOpened) ? -1 : EGROKPRF_CANTREAD;
}
// enumerate all plugins that had valid DatabasePluginInfo()
@@ -458,7 +459,7 @@ int LoadDatabaseModule(void) else
rc = tryOpenDatabase(szProfile);
- if (rc != 0) {
+ 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 (fileExist(szProfile)) {
// file isn't locked, just no driver could open it.
|