Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog/unreleased/97915
-rw-r--r--src/common/syncjournaldb.cpp10
-rw-r--r--src/common/syncjournaldb.h11
-rw-r--r--test/testpermissions.cpp1
4 files changed, 27 insertions, 0 deletions
diff --git a/changelog/unreleased/9791 b/changelog/unreleased/9791
new file mode 100644
index 000000000..2c454c717
--- /dev/null
+++ b/changelog/unreleased/9791
@@ -0,0 +1,5 @@
+Bugfix: Database was recreated after its removal
+
+We fixed a bug whre the database was recreated during the removal of a sync folder connection.
+
+https://github.com/owncloud/client/issues/9791
diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp
index b79a038b5..6bafbaa62 100644
--- a/src/common/syncjournaldb.cpp
+++ b/src/common/syncjournaldb.cpp
@@ -250,6 +250,10 @@ bool SyncJournalDb::sqlFail(const QString &log, const SqlQuery &query)
bool SyncJournalDb::checkConnect()
{
+ if (_closed) {
+ qCWarning(lcDb) << Q_FUNC_INFO << "after the db was closed";
+ return false;
+ }
if (autotestFailCounter >= 0) {
if (!autotestFailCounter--) {
qCInfo(lcDb) << "Error Simulated";
@@ -625,8 +629,14 @@ void SyncJournalDb::close()
_db.close();
clearEtagStorageFilter();
_metadataTableIsEmpty = false;
+ _closed = true;
}
+void SyncJournalDb::allowReopen()
+{
+ Q_ASSERT(_closed);
+ _closed = false;
+}
bool SyncJournalDb::updateDatabaseStructure()
{
diff --git a/src/common/syncjournaldb.h b/src/common/syncjournaldb.h
index 933fcbbee..ad68c7f11 100644
--- a/src/common/syncjournaldb.h
+++ b/src/common/syncjournaldb.h
@@ -220,6 +220,12 @@ public:
void close();
/**
+ * allow to reopen/recreate the db after it was closed (unit tests)
+ * This is usually not allowed to prevent accidential recreation of db.
+ */
+ void allowReopen();
+
+ /**
* Returns the checksum type for an id.
*/
QByteArray getChecksumType(int checksumTypeId);
@@ -413,6 +419,11 @@ private:
QByteArray _journalMode;
PreparedSqlQueryManager _queryManager;
+
+ /**
+ * Whether the db was already closed, prevent recreation
+ */
+ bool _closed = false;
};
bool OCSYNC_EXPORT
diff --git a/test/testpermissions.cpp b/test/testpermissions.cpp
index e0cafd0a3..8e611d013 100644
--- a/test/testpermissions.cpp
+++ b/test/testpermissions.cpp
@@ -39,6 +39,7 @@ static void assertCsyncJournalOk(SyncJournalDb &journal)
#if defined(Q_OS_WIN) // Make sure the file does not appear in the FileInfo
FileSystem::setFileHidden(journal.databaseFilePath() + "-shm", true);
#endif
+ journal.allowReopen();
}
SyncFileItemPtr findDiscoveryItem(const SyncFileItemSet &spy, const QString &path)