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--src/common/syncjournaldb.cpp16
-rw-r--r--src/common/syncjournaldb.h7
-rw-r--r--test/testsyncjournaldb.cpp18
3 files changed, 38 insertions, 3 deletions
diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp
index 6a580ebcf..8c441b13c 100644
--- a/src/common/syncjournaldb.cpp
+++ b/src/common/syncjournaldb.cpp
@@ -2086,6 +2086,22 @@ void SyncJournalDb::wipePinStateForPathAndBelow(const QByteArray &path)
query.exec();
}
+Optional<QVector<QPair<QByteArray, PinState>>> SyncJournalDb::rawPinStates()
+{
+ QMutexLocker lock(&_mutex);
+ if (!checkConnect())
+ return {};
+
+ SqlQuery query("SELECT path, pinState FROM flags;", _db);
+ query.exec();
+
+ QVector<QPair<QByteArray, PinState>> result;
+ while (query.next()) {
+ result.append({ query.baValue(0), static_cast<PinState>(query.intValue(1)) });
+ }
+ return result;
+}
+
void SyncJournalDb::commit(const QString &context, bool startTrans)
{
QMutexLocker lock(&_mutex);
diff --git a/src/common/syncjournaldb.h b/src/common/syncjournaldb.h
index f597a1b99..8c4243686 100644
--- a/src/common/syncjournaldb.h
+++ b/src/common/syncjournaldb.h
@@ -316,6 +316,13 @@ public:
void wipePinStateForPathAndBelow(const QByteArray &path);
/**
+ * Returns list of all paths with their pin state as in the db.
+ *
+ * Returns nothing on db error.
+ */
+ Optional<QVector<QPair<QByteArray, PinState>>> rawPinStates();
+
+ /**
* Only used for auto-test:
* when positive, will decrease the counter for every database operation.
* reaching 0 makes the operation fails
diff --git a/test/testsyncjournaldb.cpp b/test/testsyncjournaldb.cpp
index 6a0cedd72..960e9f8e3 100644
--- a/test/testsyncjournaldb.cpp
+++ b/test/testsyncjournaldb.cpp
@@ -352,7 +352,12 @@ private slots:
return *state;
};
+ _db.wipePinStateForPathAndBelow("");
+ auto list = _db.rawPinStates();
+ QCOMPARE(list->size(), 0);
+
// Make a thrice-nested setup
+ make("", PinState::AlwaysLocal);
make("local", PinState::AlwaysLocal);
make("online", PinState::OnlineOnly);
make("inherit", PinState::Inherited);
@@ -362,12 +367,15 @@ private slots:
make(QByteArray(base) + "online", PinState::OnlineOnly);
for (auto base2 : {"local/", "online/", "inherit/"}) {
- make(QByteArray(base) + base2 + "/inherit", PinState::Inherited);
- make(QByteArray(base) + base2 + "/local", PinState::AlwaysLocal);
- make(QByteArray(base) + base2 + "/online", PinState::OnlineOnly);
+ make(QByteArray(base) + base2 + "inherit", PinState::Inherited);
+ make(QByteArray(base) + base2 + "local", PinState::AlwaysLocal);
+ make(QByteArray(base) + base2 + "online", PinState::OnlineOnly);
}
}
+ list = _db.rawPinStates();
+ QCOMPARE(list->size(), 4 + 9 + 27);
+
// Baseline direct checks (the fallback for unset root pinstate is AlwaysLocal)
QCOMPARE(get("local"), PinState::AlwaysLocal);
QCOMPARE(get("online"), PinState::OnlineOnly);
@@ -417,12 +425,16 @@ private slots:
QCOMPARE(getRaw("local/local"), PinState::Inherited);
QCOMPARE(getRaw("local/local/local"), PinState::Inherited);
QCOMPARE(getRaw("local/local/online"), PinState::Inherited);
+ list = _db.rawPinStates();
+ QCOMPARE(list->size(), 4 + 9 + 27 - 4);
// Wiping everything
_db.wipePinStateForPathAndBelow("");
QCOMPARE(getRaw(""), PinState::Inherited);
QCOMPARE(getRaw("local"), PinState::Inherited);
QCOMPARE(getRaw("online"), PinState::Inherited);
+ list = _db.rawPinStates();
+ QCOMPARE(list->size(), 0);
}
private: