query.exec();
}
+void SyncJournalDb::wipePinStateForPathAndBelow(const QByteArray &path)
+{
+ QMutexLocker lock(&_mutex);
+ if (!checkConnect())
+ return;
+
+ auto &query = _wipePinStateQuery;
+ ASSERT(query.initOrReset(QByteArrayLiteral(
+ "DELETE FROM flags WHERE " IS_PREFIX_PATH_OR_EQUAL("?1", "path") ";"),
+ _db));
+ query.bindValue(1, path);
+ query.exec();
+}
+
void SyncJournalDb::commit(const QString &context, bool startTrans)
{
QMutexLocker lock(&_mutex);
*/
void setPinStateForPath(const QByteArray &path, PinState state);
+ /**
+ * Wipes pin states for a path and below.
+ *
+ * Used when the user asks a subtree to have a particular pin state.
+ */
+ void wipePinStateForPathAndBelow(const QByteArray &path);
+
/**
* Only used for auto-test:
* when positive, will decrease the counter for every database operation.
SqlQuery _getRawPinStateQuery;
SqlQuery _getEffectivePinStateQuery;
SqlQuery _setPinStateQuery;
+ SqlQuery _wipePinStateQuery;
/* Storing etags to these folders, or their parent folders, is filtered out.
*
}
return *state;
};
+ auto getRaw = [&](const QByteArray &path) -> PinState {
+ auto state = _db.rawPinStateForPath(path);
+ if (!state) {
+ QTest::qFail("couldn't read pin state", __FILE__, __LINE__);
+ return PinState::Inherited;
+ }
+ return *state;
+ };
// Make a thrice-nested setup
make("local", PinState::AlwaysLocal);
QCOMPARE(get("online"), PinState::OnlineOnly);
QCOMPARE(get("inherit"), PinState::AlwaysLocal);
QCOMPARE(get("nonexistant"), PinState::AlwaysLocal);
+
+ // Wiping
+ QCOMPARE(getRaw("local/local"), PinState::AlwaysLocal);
+ _db.wipePinStateForPathAndBelow("local/local");
+ QCOMPARE(getRaw("local"), PinState::AlwaysLocal);
+ QCOMPARE(getRaw("local/local"), PinState::Inherited);
+ QCOMPARE(getRaw("local/local/local"), PinState::Inherited);
+ QCOMPARE(getRaw("local/local/online"), PinState::Inherited);
}
private: