From 1c9b4c1afd8f269310b33ffc241b7dbdded2735b Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 11 Jun 2018 15:55:23 +0200 Subject: [PATCH] data: explicitly clear all errors when refreshing incomplete files --- src/lib/data/TaskCleanStorage.cpp | 10 ++++++++-- src/lib/data/TaskCleanStorage.h | 4 +++- src/lib/data/storage/PersistentStorage.cpp | 7 +++++++ src/lib/data/storage/PersistentStorage.h | 1 + src/lib/data/storage/sqlite/SqliteIndexStorage.cpp | 7 +++++++ src/lib/data/storage/sqlite/SqliteIndexStorage.h | 1 + src/lib/project/Project.cpp | 3 ++- 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/lib/data/TaskCleanStorage.cpp b/src/lib/data/TaskCleanStorage.cpp index 290ad342..bd0575f8 100644 --- a/src/lib/data/TaskCleanStorage.cpp +++ b/src/lib/data/TaskCleanStorage.cpp @@ -8,10 +8,11 @@ #include "Application.h" TaskCleanStorage::TaskCleanStorage( - PersistentStorage* storage, const std::vector& filePaths + PersistentStorage* storage, const std::vector& filePaths, bool clearAllErrors ) : m_storage(storage) , m_filePaths(filePaths) + , m_clearAllErrors(clearAllErrors) { } @@ -22,7 +23,7 @@ void TaskCleanStorage::doEnter(std::shared_ptr blackboard) m_start = utility::durationStart(); - if (!m_filePaths.empty()) + if (!m_filePaths.empty() || m_clearAllErrors) { m_storage->setMode(SqliteIndexStorage::STORAGE_MODE_CLEAR); } @@ -30,6 +31,11 @@ void TaskCleanStorage::doEnter(std::shared_ptr blackboard) Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr blackboard) { + if (m_clearAllErrors) + { + m_storage->clearAllErrors(); + } + m_storage->clearFileElements(m_filePaths, [=](int progress) { Application::getInstance()->getDialogView()->showProgressDialog( diff --git a/src/lib/data/TaskCleanStorage.h b/src/lib/data/TaskCleanStorage.h index f3d5e4d2..d03fec52 100644 --- a/src/lib/data/TaskCleanStorage.h +++ b/src/lib/data/TaskCleanStorage.h @@ -16,7 +16,8 @@ class TaskCleanStorage public: TaskCleanStorage( PersistentStorage* storage, - const std::vector& filePaths + const std::vector& filePaths, + bool clearAllErrors ); private: @@ -27,6 +28,7 @@ private: PersistentStorage* m_storage; std::vector m_filePaths; + bool m_clearAllErrors; TimeStamp m_start; }; diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 450f0037..acc68336 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -328,6 +328,13 @@ std::set PersistentStorage::getReferencing(const std::set& f return referencing; } +void PersistentStorage::clearAllErrors() +{ + TRACE(); + + m_sqliteIndexStorage.removeAllErrors(); +} + void PersistentStorage::clearFileElements(const std::vector& filePaths, std::function updateStatusCallback) { TRACE(); diff --git a/src/lib/data/storage/PersistentStorage.h b/src/lib/data/storage/PersistentStorage.h index 00fc0cbb..dbc847cd 100644 --- a/src/lib/data/storage/PersistentStorage.h +++ b/src/lib/data/storage/PersistentStorage.h @@ -61,6 +61,7 @@ public: std::set getReferenced(const std::set& filePaths) const; std::set getReferencing(const std::set& filePaths) const; + void clearAllErrors(); void clearFileElements(const std::vector& filePaths, std::function updateStatusCallback); std::vector getFileInfoForAllIndexedFiles() const; diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp index f9100f53..c9f23f0f 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp @@ -450,6 +450,13 @@ void SqliteIndexStorage::removeElementsWithLocationInFiles(const std::vector } } +void SqliteIndexStorage::removeAllErrors() +{ + executeStatement( + "DELETE FROM error;" + ); +} + void SqliteIndexStorage::removeErrorsInFiles(const std::vector& filePaths) { executeStatement( diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.h b/src/lib/data/storage/sqlite/SqliteIndexStorage.h index ace7d3a3..2de507c3 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.h +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.h @@ -54,6 +54,7 @@ public: void removeElements(const std::vector& ids); void removeElementsWithLocationInFiles(const std::vector& fileIds, std::function updateStatusCallback); + void removeAllErrors(); void removeErrorsInFiles(const std::vector& filePaths); bool isEdge(Id elementId) const; diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 06b3deb9..ddd06a82 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -356,7 +356,8 @@ void Project::buildIndex(const RefreshInfo& info, DialogView* dialogView) { taskSequential->addTask(std::make_shared( m_storage.get(), - utility::toVector(utility::concat(info.filesToClear, info.nonIndexedFilesToClear)) + utility::toVector(utility::concat(info.filesToClear, info.nonIndexedFilesToClear)), + info.mode == REFRESH_UPDATED_AND_INCOMPLETE_FILES )); }