From b67369c7256dc40eb7aa7b3527c1cb45e2a27b27 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 30 Dec 2013 15:31:43 +0000 Subject: 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 --- src/modules/database/database.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/modules') 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. -- cgit v1.2.3