From e287c863156cdd089925f2c33d93547491510260 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Wed, 20 Jun 2018 23:56:18 +0200 Subject: [PATCH] data: Allow a complete file to become incomplete again if it has errors in a later translation unit --- src/lib/data/storage/PersistentStorage.cpp | 2 +- src/lib/data/storage/sqlite/SqliteIndexStorage.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib/data/storage/PersistentStorage.cpp b/src/lib/data/storage/PersistentStorage.cpp index 7cfc3e2b..0f387459 100644 --- a/src/lib/data/storage/PersistentStorage.cpp +++ b/src/lib/data/storage/PersistentStorage.cpp @@ -90,7 +90,7 @@ void PersistentStorage::addFile(const StorageFile& data) m_sqliteIndexStorage.setFileIndexed(storedFile.id, data.indexed); } - if (!storedFile.complete && data.complete) + if (storedFile.complete != data.complete) { m_sqliteIndexStorage.setFileCompleteIfNoError(storedFile.id, storedFile.filePath, data.complete); } diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp index 611d9622..9f370357 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp @@ -650,15 +650,13 @@ void SqliteIndexStorage::setFileIndexed(Id fileId, bool indexed) void SqliteIndexStorage::setFileCompleteIfNoError(Id fileId, const std::wstring& filePath, bool complete) { - StorageError error = doGetFirst("WHERE file_path == '" + utility::encodeToUtf8(filePath) + "'"); - if (error.id) + bool fileHasErrors = doGetFirst("WHERE file_path == '" + utility::encodeToUtf8(filePath) + "'").id; + if (fileHasErrors != complete) { - return; + executeStatement( + "UPDATE file SET complete = " + std::to_string(complete) + " WHERE id == " + std::to_string(fileId) + ";" + ); } - - executeStatement( - "UPDATE file SET complete = " + std::to_string(complete) + " WHERE id == " + std::to_string(fileId) + ";" - ); } void SqliteIndexStorage::setNodeType(int type, Id nodeId)