From 3f60f7a83cc6f19cd7324aceb31ae7aa44bc40e8 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Fri, 12 Jan 2018 19:57:11 +0100 Subject: [PATCH] data: Still allow project refresh if database file can't be loaded --- .../data/storage/sqlite/SqliteIndexStorage.cpp | 2 -- src/lib/project/Project.cpp | 18 +++++++++++++++++- src/lib/project/Project.h | 3 ++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp index dc2290fa..821c8603 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp @@ -964,8 +964,6 @@ void SqliteIndexStorage::setupTables() LOG_ERROR(std::to_string(e.errorCode()) + ": " + e.errorMessage()); throw(std::exception()); - - // todo: cancel project creation and destroy created files, display message } } diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index ecb3f53b..46bab870 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -121,7 +121,17 @@ void Project::load() canLoad = true; } - m_storage->setup(); + try + { + m_storage->setup(); + } + catch(...) + { + LOG_ERROR_STREAM(<< "Exception during storage loading."); + + canLoad = false; + m_state = PROJECT_STATE_DB_CORRUPTED; + } m_sourceGroups = SourceGroupFactory::getInstance()->createSourceGroups(m_settings->getAllSourceGroupSettings()); @@ -197,6 +207,12 @@ void Project::refresh(RefreshMode refreshMode, DialogView* dialogView) "the project fully reindexed. Do you want to update the project file and reindex the project?"; needsFullRefresh = true; + case PROJECT_STATE_DB_CORRUPTED: + question = + "There was a problem loading the index of this project. The project needs to get fully reindexed. " + "Do you want to reindex the project?"; + needsFullRefresh = true; + default: break; } diff --git a/src/lib/project/Project.h b/src/lib/project/Project.h index abd7326c..4e727bc3 100644 --- a/src/lib/project/Project.h +++ b/src/lib/project/Project.h @@ -45,7 +45,8 @@ private: PROJECT_STATE_OUTDATED, PROJECT_STATE_OUTVERSIONED, PROJECT_STATE_SETTINGS_UPDATED, - PROJECT_STATE_NEEDS_MIGRATION + PROJECT_STATE_NEEDS_MIGRATION, + PROJECT_STATE_DB_CORRUPTED }; Project(const Project&);