testlocaldiscovery.cpp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. /*
  2. * This software is in the public domain, furnished "as is", without technical
  3. * support, and with no warranty, express or implied, as to its usefulness for
  4. * any purpose.
  5. *
  6. */
  7. #include <QtTest>
  8. #include "syncenginetestutils.h"
  9. #include <syncengine.h>
  10. #include <localdiscoverytracker.h>
  11. using namespace OCC;
  12. class TestLocalDiscovery : public QObject
  13. {
  14. Q_OBJECT
  15. private slots:
  16. void testSelectiveSyncQuotaExceededDataLoss()
  17. {
  18. FakeFolder fakeFolder{FileInfo{}};
  19. // folders that fit the quota
  20. fakeFolder.localModifier().mkdir("big-files");
  21. fakeFolder.localModifier().insert("big-files/bigfile_A.data", 1000);
  22. fakeFolder.localModifier().insert("big-files/bigfile_B.data", 1000);
  23. fakeFolder.localModifier().insert("big-files/bigfile_C.data", 1000);
  24. fakeFolder.localModifier().mkdir("more-big-files");
  25. fakeFolder.localModifier().insert("more-big-files/bigfile_A.data", 1000);
  26. fakeFolder.localModifier().insert("more-big-files/bigfile_B.data", 1000);
  27. fakeFolder.localModifier().insert("more-big-files/bigfile_C.data", 1000);
  28. QVERIFY(fakeFolder.syncOnce());
  29. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  30. // folders that won't fit
  31. fakeFolder.localModifier().mkdir("big-files-wont-fit");
  32. fakeFolder.localModifier().insert("big-files-wont-fit/bigfile_A.data", 800);
  33. fakeFolder.localModifier().insert("big-files-wont-fit/bigfile_B.data", 800);
  34. fakeFolder.localModifier().mkdir("more-big-files-wont-fit");
  35. fakeFolder.localModifier().insert("more-big-files-wont-fit/bigfile_A.data", 800);
  36. fakeFolder.localModifier().insert("more-big-files-wont-fit/bigfile_B.data", 800);
  37. const auto remoteQuota = 600;
  38. QObject parent;
  39. fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData) -> QNetworkReply * {
  40. Q_UNUSED(outgoingData)
  41. if (op == QNetworkAccessManager::PutOperation) {
  42. if (request.rawHeader("OC-Total-Length").toInt() > remoteQuota) {
  43. return new FakeErrorReply(op, request, &parent, 507);
  44. }
  45. }
  46. return nullptr;
  47. });
  48. QVERIFY(!fakeFolder.syncOnce());
  49. fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, {"big-files-wont-fit/", "more-big-files-wont-fit/"});
  50. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, {"big-files-wont-fit/", "more-big-files-wont-fit/"});
  51. QVERIFY(fakeFolder.syncEngine().journal()->wipeErrorBlacklist());
  52. QVERIFY(fakeFolder.syncOnce());
  53. QVERIFY(fakeFolder.currentLocalState().find("big-files-wont-fit/bigfile_A.data"));
  54. QVERIFY(fakeFolder.currentLocalState().find("big-files-wont-fit/bigfile_B.data"));
  55. QVERIFY(fakeFolder.currentLocalState().find("more-big-files-wont-fit/bigfile_A.data"));
  56. QVERIFY(fakeFolder.currentLocalState().find("more-big-files-wont-fit/bigfile_B.data"));
  57. QVERIFY(!fakeFolder.currentRemoteState().find("big-files-wont-fit/bigfile_A.data"));
  58. QVERIFY(!fakeFolder.currentRemoteState().find("big-files-wont-fit/bigfile_B.data"));
  59. QVERIFY(!fakeFolder.currentRemoteState().find("more-big-files-wont-fit/bigfile_A.data"));
  60. QVERIFY(!fakeFolder.currentRemoteState().find("more-big-files-wont-fit/bigfile_B.data"));
  61. fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, {"big-files-wont-fit/", "more-big-files-wont-fit/", "big-files/"});
  62. fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, {"more-big-files/"});
  63. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, {"big-files/", "more-big-files/"});
  64. QVERIFY(fakeFolder.syncOnce());
  65. QVERIFY(fakeFolder.currentLocalState().find("big-files-wont-fit/bigfile_A.data"));
  66. QVERIFY(fakeFolder.currentLocalState().find("big-files-wont-fit/bigfile_B.data"));
  67. QVERIFY(fakeFolder.currentLocalState().find("more-big-files-wont-fit/bigfile_A.data"));
  68. QVERIFY(fakeFolder.currentLocalState().find("more-big-files-wont-fit/bigfile_B.data"));
  69. QVERIFY(!fakeFolder.currentRemoteState().find("big-files-wont-fit/bigfile_A.data"));
  70. QVERIFY(!fakeFolder.currentRemoteState().find("big-files-wont-fit/bigfile_B.data"));
  71. QVERIFY(!fakeFolder.currentRemoteState().find("more-big-files-wont-fit/bigfile_A.data"));
  72. QVERIFY(!fakeFolder.currentRemoteState().find("more-big-files-wont-fit/bigfile_B.data"));
  73. fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList, {"big-files/", "more-big-files/"});
  74. fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, {"big-files-wont-fit/", "more-big-files-wont-fit/"});
  75. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, {"big-files/", "more-big-files/"});
  76. QVERIFY(fakeFolder.syncOnce());
  77. QVERIFY(fakeFolder.currentLocalState().find("big-files-wont-fit/bigfile_A.data"));
  78. QVERIFY(fakeFolder.currentLocalState().find("big-files-wont-fit/bigfile_B.data"));
  79. QVERIFY(fakeFolder.currentLocalState().find("more-big-files-wont-fit/bigfile_A.data"));
  80. QVERIFY(fakeFolder.currentLocalState().find("more-big-files-wont-fit/bigfile_B.data"));
  81. QVERIFY(!fakeFolder.currentRemoteState().find("big-files-wont-fit/bigfile_A.data"));
  82. QVERIFY(!fakeFolder.currentRemoteState().find("big-files-wont-fit/bigfile_B.data"));
  83. QVERIFY(!fakeFolder.currentRemoteState().find("more-big-files-wont-fit/bigfile_A.data"));
  84. QVERIFY(!fakeFolder.currentRemoteState().find("more-big-files-wont-fit/bigfile_B.data"));
  85. }
  86. // Check correct behavior when local discovery is partially drawn from the db
  87. void testLocalDiscoveryStyle()
  88. {
  89. FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
  90. LocalDiscoveryTracker tracker;
  91. connect(&fakeFolder.syncEngine(), &SyncEngine::itemCompleted, &tracker, &LocalDiscoveryTracker::slotItemCompleted);
  92. connect(&fakeFolder.syncEngine(), &SyncEngine::finished, &tracker, &LocalDiscoveryTracker::slotSyncFinished);
  93. // More subdirectories are useful for testing
  94. fakeFolder.localModifier().mkdir("A/X");
  95. fakeFolder.localModifier().mkdir("A/Y");
  96. fakeFolder.localModifier().insert("A/X/x1");
  97. fakeFolder.localModifier().insert("A/Y/y1");
  98. tracker.addTouchedPath("A/X");
  99. tracker.startSyncFullDiscovery();
  100. QVERIFY(fakeFolder.syncOnce());
  101. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  102. QVERIFY(tracker.localDiscoveryPaths().empty());
  103. // Test begins
  104. fakeFolder.localModifier().insert("A/a3");
  105. fakeFolder.localModifier().insert("A/X/x2");
  106. fakeFolder.localModifier().insert("A/Y/y2");
  107. fakeFolder.localModifier().insert("B/b3");
  108. fakeFolder.remoteModifier().insert("C/c3");
  109. fakeFolder.remoteModifier().appendByte("C/c1");
  110. tracker.addTouchedPath("A/X");
  111. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, tracker.localDiscoveryPaths());
  112. tracker.startSyncPartialDiscovery();
  113. QVERIFY(fakeFolder.syncOnce());
  114. QVERIFY(fakeFolder.currentRemoteState().find("A/a3"));
  115. QVERIFY(fakeFolder.currentRemoteState().find("A/X/x2"));
  116. QVERIFY(!fakeFolder.currentRemoteState().find("A/Y/y2"));
  117. QVERIFY(!fakeFolder.currentRemoteState().find("B/b3"));
  118. QVERIFY(fakeFolder.currentLocalState().find("C/c3"));
  119. QCOMPARE(fakeFolder.syncEngine().lastLocalDiscoveryStyle(), LocalDiscoveryStyle::DatabaseAndFilesystem);
  120. QVERIFY(tracker.localDiscoveryPaths().empty());
  121. QVERIFY(fakeFolder.syncOnce());
  122. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  123. QCOMPARE(fakeFolder.syncEngine().lastLocalDiscoveryStyle(), LocalDiscoveryStyle::FilesystemOnly);
  124. QVERIFY(tracker.localDiscoveryPaths().empty());
  125. }
  126. void testLocalDiscoveryDecision()
  127. {
  128. FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
  129. auto &engine = fakeFolder.syncEngine();
  130. QVERIFY(engine.shouldDiscoverLocally(""));
  131. QVERIFY(engine.shouldDiscoverLocally("A"));
  132. QVERIFY(engine.shouldDiscoverLocally("A/X"));
  133. fakeFolder.syncEngine().setLocalDiscoveryOptions(
  134. LocalDiscoveryStyle::DatabaseAndFilesystem,
  135. { "A/X", "A/X space", "A/X/beta", "foo bar space/touch", "foo/", "zzz", "zzzz" });
  136. QVERIFY(engine.shouldDiscoverLocally(""));
  137. QVERIFY(engine.shouldDiscoverLocally("A"));
  138. QVERIFY(engine.shouldDiscoverLocally("A/X"));
  139. QVERIFY(!engine.shouldDiscoverLocally("B"));
  140. QVERIFY(!engine.shouldDiscoverLocally("A B"));
  141. QVERIFY(!engine.shouldDiscoverLocally("B/X"));
  142. QVERIFY(engine.shouldDiscoverLocally("foo bar space"));
  143. QVERIFY(engine.shouldDiscoverLocally("foo"));
  144. QVERIFY(!engine.shouldDiscoverLocally("foo bar"));
  145. QVERIFY(!engine.shouldDiscoverLocally("foo bar/touch"));
  146. // These are within "A/X" so they should be discovered
  147. QVERIFY(engine.shouldDiscoverLocally("A/X/alpha"));
  148. QVERIFY(engine.shouldDiscoverLocally("A/X beta"));
  149. QVERIFY(engine.shouldDiscoverLocally("A/X/Y"));
  150. QVERIFY(engine.shouldDiscoverLocally("A/X space"));
  151. QVERIFY(engine.shouldDiscoverLocally("A/X space/alpha"));
  152. QVERIFY(!engine.shouldDiscoverLocally("A/Xylo/foo"));
  153. QVERIFY(engine.shouldDiscoverLocally("zzzz/hello"));
  154. QVERIFY(!engine.shouldDiscoverLocally("zzza/hello"));
  155. QEXPECT_FAIL("", "There is a possibility of false positives if the set contains a path "
  156. "which is a prefix, and that prefix is followed by a character less than '/'", Continue);
  157. QVERIFY(!engine.shouldDiscoverLocally("A/X o"));
  158. fakeFolder.syncEngine().setLocalDiscoveryOptions(
  159. LocalDiscoveryStyle::DatabaseAndFilesystem,
  160. {});
  161. QVERIFY(!engine.shouldDiscoverLocally(""));
  162. }
  163. // Check whether item success and item failure adjusts the
  164. // tracker correctly.
  165. void testTrackerItemCompletion()
  166. {
  167. FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
  168. LocalDiscoveryTracker tracker;
  169. connect(&fakeFolder.syncEngine(), &SyncEngine::itemCompleted, &tracker, &LocalDiscoveryTracker::slotItemCompleted);
  170. connect(&fakeFolder.syncEngine(), &SyncEngine::finished, &tracker, &LocalDiscoveryTracker::slotSyncFinished);
  171. auto trackerContains = [&](const char *path) {
  172. return tracker.localDiscoveryPaths().find(path) != tracker.localDiscoveryPaths().end();
  173. };
  174. tracker.addTouchedPath("A/spurious");
  175. fakeFolder.localModifier().insert("A/a3");
  176. tracker.addTouchedPath("A/a3");
  177. fakeFolder.localModifier().insert("A/a4");
  178. fakeFolder.serverErrorPaths().append("A/a4");
  179. // We're not adding a4 as touched, it's in the same folder as a3 and will be seen.
  180. // And due to the error it should be added to the explicit list while a3 gets removed.
  181. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, tracker.localDiscoveryPaths());
  182. tracker.startSyncPartialDiscovery();
  183. QVERIFY(!fakeFolder.syncOnce());
  184. QVERIFY(fakeFolder.currentRemoteState().find("A/a3"));
  185. QVERIFY(!fakeFolder.currentRemoteState().find("A/a4"));
  186. QVERIFY(!trackerContains("A/a3"));
  187. QVERIFY(trackerContains("A/a4"));
  188. QVERIFY(trackerContains("A/spurious")); // not removed since overall sync not successful
  189. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::FilesystemOnly);
  190. tracker.startSyncFullDiscovery();
  191. QVERIFY(!fakeFolder.syncOnce());
  192. QVERIFY(!fakeFolder.currentRemoteState().find("A/a4"));
  193. QVERIFY(trackerContains("A/a4")); // had an error, still here
  194. QVERIFY(!trackerContains("A/spurious")); // removed due to full discovery
  195. fakeFolder.serverErrorPaths().clear();
  196. QVERIFY(fakeFolder.syncJournal().wipeErrorBlacklist() != -1);
  197. tracker.addTouchedPath("A/newspurious"); // will be removed due to successful sync
  198. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, tracker.localDiscoveryPaths());
  199. tracker.startSyncPartialDiscovery();
  200. QVERIFY(fakeFolder.syncOnce());
  201. QVERIFY(fakeFolder.currentRemoteState().find("A/a4"));
  202. QVERIFY(tracker.localDiscoveryPaths().empty());
  203. }
  204. void testDirectoryAndSubDirectory()
  205. {
  206. FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
  207. fakeFolder.localModifier().mkdir("A/newDir");
  208. fakeFolder.localModifier().mkdir("A/newDir/subDir");
  209. fakeFolder.localModifier().insert("A/newDir/subDir/file", 10);
  210. auto expectedState = fakeFolder.currentLocalState();
  211. // Only "A" was modified according to the file system tracker
  212. fakeFolder.syncEngine().setLocalDiscoveryOptions(
  213. LocalDiscoveryStyle::DatabaseAndFilesystem,
  214. { "A" });
  215. QVERIFY(fakeFolder.syncOnce());
  216. QCOMPARE(fakeFolder.currentLocalState(), expectedState);
  217. QCOMPARE(fakeFolder.currentRemoteState(), expectedState);
  218. }
  219. // Tests the behavior of invalid filename detection
  220. void testServerBlacklist()
  221. {
  222. FakeFolder fakeFolder { FileInfo::A12_B12_C12_S12() };
  223. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  224. fakeFolder.syncEngine().account()->setCapabilities({ { "files",
  225. QVariantMap { { "blacklisted_files", QVariantList { ".foo", "bar" } } } } });
  226. fakeFolder.localModifier().insert("C/.foo");
  227. fakeFolder.localModifier().insert("C/bar");
  228. fakeFolder.localModifier().insert("C/moo");
  229. fakeFolder.localModifier().insert("C/.moo");
  230. QVERIFY(fakeFolder.syncOnce());
  231. QVERIFY(fakeFolder.currentRemoteState().find("C/moo"));
  232. QVERIFY(fakeFolder.currentRemoteState().find("C/.moo"));
  233. QVERIFY(!fakeFolder.currentRemoteState().find("C/.foo"));
  234. QVERIFY(!fakeFolder.currentRemoteState().find("C/bar"));
  235. }
  236. void testCreateFileWithTrailingSpaces_localAndRemoteTrimmedDoNotExist_renameAndUploadFile()
  237. {
  238. FakeFolder fakeFolder{FileInfo{}};
  239. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  240. const QString fileWithSpaces1(" foo");
  241. const QString fileWithSpaces2(" bar ");
  242. const QString fileWithSpaces3("bla ");
  243. const QString fileWithSpaces4("A/ foo");
  244. const QString fileWithSpaces5("A/ bar ");
  245. const QString fileWithSpaces6("A/bla ");
  246. fakeFolder.localModifier().insert(fileWithSpaces1);
  247. fakeFolder.localModifier().insert(fileWithSpaces2);
  248. fakeFolder.localModifier().insert(fileWithSpaces3);
  249. fakeFolder.localModifier().mkdir("A");
  250. fakeFolder.localModifier().insert(fileWithSpaces4);
  251. fakeFolder.localModifier().insert(fileWithSpaces5);
  252. fakeFolder.localModifier().insert(fileWithSpaces6);
  253. fakeFolder.localModifier().mkdir(QStringLiteral(" with spaces "));
  254. ItemCompletedSpy completeSpy(fakeFolder);
  255. completeSpy.clear();
  256. QVERIFY(fakeFolder.syncOnce());
  257. QCOMPARE(completeSpy.findItem(fileWithSpaces1)->_status, SyncFileItem::Status::FileNameInvalid);
  258. QCOMPARE(completeSpy.findItem(fileWithSpaces2)->_status, SyncFileItem::Status::FileNameInvalid);
  259. QCOMPARE(completeSpy.findItem(fileWithSpaces3)->_status, SyncFileItem::Status::FileNameInvalid);
  260. QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::FileNameInvalid);
  261. QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::FileNameInvalid);
  262. QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::FileNameInvalid);
  263. QCOMPARE(completeSpy.findItem(QStringLiteral(" with spaces "))->_status, SyncFileItem::Status::FileNameInvalid);
  264. fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces1);
  265. fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces2);
  266. fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces3);
  267. fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces4);
  268. fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces5);
  269. fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces6);
  270. fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + QStringLiteral(" with spaces "));
  271. completeSpy.clear();
  272. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, {QStringLiteral("foo"), QStringLiteral("bar"), QStringLiteral("bla"), QStringLiteral("A/foo"), QStringLiteral("A/bar"), QStringLiteral("A/bla")});
  273. QVERIFY(fakeFolder.syncOnce());
  274. QCOMPARE(completeSpy.findItem(fileWithSpaces1)->_status, SyncFileItem::Status::Success);
  275. QCOMPARE(completeSpy.findItem(fileWithSpaces2)->_status, SyncFileItem::Status::Success);
  276. QCOMPARE(completeSpy.findItem(fileWithSpaces3)->_status, SyncFileItem::Status::Success);
  277. QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::Success);
  278. QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::Success);
  279. QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::Success);
  280. QCOMPARE(completeSpy.findItem(QStringLiteral(" with spaces "))->_status, SyncFileItem::Status::Success);
  281. }
  282. void testCreateFileWithTrailingSpaces_remoteDontGetRenamedAutomatically()
  283. {
  284. // On Windows we can't create files/folders with leading/trailing spaces locally. So, we have to fail those items. On other OSs - we just sync them down normally.
  285. FakeFolder fakeFolder{FileInfo()};
  286. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  287. const QString fileWithSpaces4("A/ foo");
  288. const QString fileWithSpaces5("A/ bar ");
  289. const QString fileWithSpaces6("A/bla ");
  290. fakeFolder.remoteModifier().mkdir("A");
  291. fakeFolder.remoteModifier().insert(fileWithSpaces4);
  292. fakeFolder.remoteModifier().insert(fileWithSpaces5);
  293. fakeFolder.remoteModifier().insert(fileWithSpaces6);
  294. ItemCompletedSpy completeSpy(fakeFolder);
  295. completeSpy.clear();
  296. QVERIFY(fakeFolder.syncOnce());
  297. if (Utility::isWindows()) {
  298. QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::FileNameInvalid);
  299. QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::FileNameInvalid);
  300. QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::FileNameInvalid);
  301. } else {
  302. QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::Success);
  303. QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::Success);
  304. QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::Success);
  305. }
  306. }
  307. void testCreateFileWithTrailingSpaces_remoteGetRenamedManually()
  308. {
  309. // On Windows we can't create files/folders with leading/trailing spaces locally. So, we have to fail those items. On other OSs - we just sync them down normally.
  310. FakeFolder fakeFolder{FileInfo()};
  311. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  312. const QString fileWithSpaces4("A/ foo");
  313. const QString fileWithSpaces5("A/ bar ");
  314. const QString fileWithSpaces6("A/bla ");
  315. const QString fileWithoutSpaces4("A/foo");
  316. const QString fileWithoutSpaces5("A/bar");
  317. const QString fileWithoutSpaces6("A/bla");
  318. fakeFolder.remoteModifier().mkdir("A");
  319. fakeFolder.remoteModifier().insert(fileWithSpaces4);
  320. fakeFolder.remoteModifier().insert(fileWithSpaces5);
  321. fakeFolder.remoteModifier().insert(fileWithSpaces6);
  322. ItemCompletedSpy completeSpy(fakeFolder);
  323. completeSpy.clear();
  324. QVERIFY(fakeFolder.syncOnce());
  325. if (Utility::isWindows()) {
  326. QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::FileNameInvalid);
  327. QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::FileNameInvalid);
  328. QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::FileNameInvalid);
  329. } else {
  330. QCOMPARE(completeSpy.findItem(fileWithSpaces4)->_status, SyncFileItem::Status::Success);
  331. QCOMPARE(completeSpy.findItem(fileWithSpaces5)->_status, SyncFileItem::Status::Success);
  332. QCOMPARE(completeSpy.findItem(fileWithSpaces6)->_status, SyncFileItem::Status::Success);
  333. }
  334. fakeFolder.remoteModifier().rename(fileWithSpaces4, fileWithoutSpaces4);
  335. fakeFolder.remoteModifier().rename(fileWithSpaces5, fileWithoutSpaces5);
  336. fakeFolder.remoteModifier().rename(fileWithSpaces6, fileWithoutSpaces6);
  337. completeSpy.clear();
  338. QVERIFY(fakeFolder.syncOnce());
  339. QCOMPARE(completeSpy.findItem(fileWithoutSpaces4)->_status, SyncFileItem::Status::Success);
  340. QCOMPARE(completeSpy.findItem(fileWithoutSpaces5)->_status, SyncFileItem::Status::Success);
  341. QCOMPARE(completeSpy.findItem(fileWithoutSpaces6)->_status, SyncFileItem::Status::Success);
  342. }
  343. void testCreateFileWithTrailingSpaces_localTrimmedAlsoCreated_dontRenameAutomaticallyAndDontUploadFile()
  344. {
  345. FakeFolder fakeFolder{FileInfo{}};
  346. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  347. const QString fileWithSpaces(" foo");
  348. const QString fileTrimmed("foo");
  349. fakeFolder.localModifier().insert(fileTrimmed);
  350. fakeFolder.localModifier().insert(fileWithSpaces);
  351. QVERIFY(fakeFolder.syncOnce());
  352. QVERIFY(fakeFolder.currentRemoteState().find(fileTrimmed));
  353. QVERIFY(!fakeFolder.currentRemoteState().find(fileWithSpaces));
  354. QVERIFY(fakeFolder.currentLocalState().find(fileWithSpaces));
  355. QVERIFY(fakeFolder.currentLocalState().find(fileTrimmed));
  356. }
  357. void testCreateFileWithTrailingSpaces_localTrimmedAlsoCreated_dontRenameAutomaticallyAndUploadBothFiles()
  358. {
  359. FakeFolder fakeFolder{FileInfo{}};
  360. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  361. const QString fileWithSpaces(" foo");
  362. const QString fileTrimmed("foo");
  363. fakeFolder.localModifier().insert(fileTrimmed);
  364. fakeFolder.localModifier().insert(fileWithSpaces);
  365. fakeFolder.syncEngine().addAcceptedInvalidFileName(fakeFolder.localPath() + fileWithSpaces);
  366. QVERIFY(fakeFolder.syncOnce());
  367. QVERIFY(fakeFolder.currentRemoteState().find(fileTrimmed));
  368. QVERIFY(fakeFolder.currentRemoteState().find(fileWithSpaces));
  369. QVERIFY(fakeFolder.currentLocalState().find(fileWithSpaces));
  370. QVERIFY(fakeFolder.currentLocalState().find(fileTrimmed));
  371. }
  372. void testCreateFileWithTrailingSpaces_localAndRemoteTrimmedExists_renameFile()
  373. {
  374. FakeFolder fakeFolder{FileInfo{}};
  375. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  376. const QString fileWithSpaces1(" foo");
  377. const QString fileWithSpaces2(" bar ");
  378. const QString fileWithSpaces3("bla ");
  379. fakeFolder.localModifier().insert(fileWithSpaces1);
  380. fakeFolder.localModifier().insert(fileWithSpaces2);
  381. fakeFolder.localModifier().insert(fileWithSpaces3);
  382. fakeFolder.remoteModifier().insert(fileWithSpaces1);
  383. fakeFolder.remoteModifier().insert(fileWithSpaces2);
  384. fakeFolder.remoteModifier().insert(fileWithSpaces3);
  385. QVERIFY(fakeFolder.syncOnce());
  386. QVERIFY(fakeFolder.syncOnce());
  387. QVERIFY(fakeFolder.syncOnce());
  388. auto expectedState = fakeFolder.currentLocalState();
  389. qDebug() << expectedState;
  390. QCOMPARE(fakeFolder.currentRemoteState(), expectedState);
  391. }
  392. void testBlockInvalidMtimeSyncRemote()
  393. {
  394. constexpr auto INVALID_MODTIME1 = 0;
  395. constexpr auto INVALID_MODTIME2 = -3600;
  396. FakeFolder fakeFolder{FileInfo{}};
  397. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  398. const QString fooFileRootFolder("foo");
  399. const QString barFileRootFolder("bar");
  400. const QString blaFileRootFolder("bla");
  401. const QString fooFileSubFolder("subfolder/foo");
  402. const QString barFileSubFolder("subfolder/bar");
  403. const QString blaFileSubFolder("subfolder/bla");
  404. fakeFolder.remoteModifier().insert(fooFileRootFolder);
  405. fakeFolder.remoteModifier().insert(barFileRootFolder);
  406. fakeFolder.remoteModifier().insert(blaFileRootFolder);
  407. fakeFolder.remoteModifier().mkdir(QStringLiteral("subfolder"));
  408. fakeFolder.remoteModifier().insert(fooFileSubFolder);
  409. fakeFolder.remoteModifier().insert(barFileSubFolder);
  410. fakeFolder.remoteModifier().insert(blaFileSubFolder);
  411. QVERIFY(fakeFolder.syncOnce());
  412. fakeFolder.remoteModifier().setModTime(fooFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  413. fakeFolder.remoteModifier().setModTime(barFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  414. fakeFolder.remoteModifier().setModTime(blaFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  415. fakeFolder.remoteModifier().setModTime(fooFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  416. fakeFolder.remoteModifier().setModTime(barFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  417. fakeFolder.remoteModifier().setModTime(blaFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  418. QVERIFY(!fakeFolder.syncOnce());
  419. QVERIFY(!fakeFolder.syncOnce());
  420. fakeFolder.remoteModifier().setModTime(fooFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  421. fakeFolder.remoteModifier().setModTime(barFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  422. fakeFolder.remoteModifier().setModTime(blaFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  423. fakeFolder.remoteModifier().setModTime(fooFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  424. fakeFolder.remoteModifier().setModTime(barFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  425. fakeFolder.remoteModifier().setModTime(blaFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  426. QVERIFY(!fakeFolder.syncOnce());
  427. QVERIFY(!fakeFolder.syncOnce());
  428. }
  429. void testBlockInvalidMtimeSyncLocal()
  430. {
  431. constexpr auto INVALID_MODTIME1 = 0;
  432. constexpr auto INVALID_MODTIME2 = -3600;
  433. FakeFolder fakeFolder{FileInfo{}};
  434. int nGET = 0;
  435. fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &, QIODevice *) {
  436. if (op == QNetworkAccessManager::GetOperation)
  437. ++nGET;
  438. return nullptr;
  439. });
  440. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  441. const QString fooFileRootFolder("foo");
  442. const QString barFileRootFolder("bar");
  443. const QString blaFileRootFolder("bla");
  444. const QString fooFileSubFolder("subfolder/foo");
  445. const QString barFileSubFolder("subfolder/bar");
  446. const QString blaFileSubFolder("subfolder/bla");
  447. fakeFolder.remoteModifier().insert(fooFileRootFolder);
  448. fakeFolder.remoteModifier().insert(barFileRootFolder);
  449. fakeFolder.remoteModifier().insert(blaFileRootFolder);
  450. fakeFolder.remoteModifier().mkdir(QStringLiteral("subfolder"));
  451. fakeFolder.remoteModifier().insert(fooFileSubFolder);
  452. fakeFolder.remoteModifier().insert(barFileSubFolder);
  453. fakeFolder.remoteModifier().insert(blaFileSubFolder);
  454. QVERIFY(fakeFolder.syncOnce());
  455. nGET = 0;
  456. fakeFolder.localModifier().setModTime(fooFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  457. fakeFolder.localModifier().setModTime(barFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  458. fakeFolder.localModifier().setModTime(blaFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  459. fakeFolder.localModifier().setModTime(fooFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  460. fakeFolder.localModifier().setModTime(barFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  461. fakeFolder.localModifier().setModTime(blaFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME1));
  462. QVERIFY(fakeFolder.syncOnce());
  463. QCOMPARE(nGET, 0);
  464. QVERIFY(fakeFolder.syncOnce());
  465. QCOMPARE(nGET, 0);
  466. fakeFolder.localModifier().setModTime(fooFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  467. fakeFolder.localModifier().setModTime(barFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  468. fakeFolder.localModifier().setModTime(blaFileRootFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  469. fakeFolder.localModifier().setModTime(fooFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  470. fakeFolder.localModifier().setModTime(barFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  471. fakeFolder.localModifier().setModTime(blaFileSubFolder, QDateTime::fromSecsSinceEpoch(INVALID_MODTIME2));
  472. QVERIFY(fakeFolder.syncOnce());
  473. QCOMPARE(nGET, 0);
  474. QVERIFY(fakeFolder.syncOnce());
  475. QCOMPARE(nGET, 0);
  476. }
  477. void testDoNotSyncInvalidFutureMtime()
  478. {
  479. constexpr auto FUTURE_MTIME = 0xFFFFFFFF;
  480. constexpr auto CURRENT_MTIME = 1646057277;
  481. FakeFolder fakeFolder{FileInfo{}};
  482. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  483. const QString fooFileRootFolder("foo");
  484. const QString barFileRootFolder("bar");
  485. const QString fooFileSubFolder("subfolder/foo");
  486. const QString barFileSubFolder("subfolder/bar");
  487. const QString fooFileAaaSubFolder("aaa/subfolder/foo");
  488. const QString barFileAaaSubFolder("aaa/subfolder/bar");
  489. fakeFolder.remoteModifier().insert(fooFileRootFolder);
  490. fakeFolder.remoteModifier().insert(barFileRootFolder);
  491. fakeFolder.remoteModifier().mkdir(QStringLiteral("subfolder"));
  492. fakeFolder.remoteModifier().insert(fooFileSubFolder);
  493. fakeFolder.remoteModifier().insert(barFileSubFolder);
  494. fakeFolder.remoteModifier().mkdir(QStringLiteral("aaa"));
  495. fakeFolder.remoteModifier().mkdir(QStringLiteral("aaa/subfolder"));
  496. fakeFolder.remoteModifier().insert(fooFileAaaSubFolder);
  497. fakeFolder.remoteModifier().insert(barFileAaaSubFolder);
  498. QVERIFY(fakeFolder.syncOnce());
  499. fakeFolder.remoteModifier().setModTime(fooFileRootFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  500. fakeFolder.remoteModifier().setModTime(barFileRootFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  501. fakeFolder.remoteModifier().setModTime(fooFileSubFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  502. fakeFolder.remoteModifier().setModTime(barFileSubFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  503. fakeFolder.remoteModifier().setModTime(fooFileAaaSubFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  504. fakeFolder.remoteModifier().setModTime(barFileAaaSubFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  505. fakeFolder.localModifier().setModTime(fooFileRootFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  506. fakeFolder.localModifier().setModTime(barFileRootFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  507. fakeFolder.localModifier().setModTime(fooFileSubFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  508. fakeFolder.localModifier().setModTime(barFileSubFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  509. fakeFolder.localModifier().setModTime(fooFileAaaSubFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  510. fakeFolder.localModifier().setModTime(barFileAaaSubFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  511. QVERIFY(!fakeFolder.syncOnce());
  512. }
  513. void testInvalidFutureMtimeRecovery()
  514. {
  515. constexpr auto FUTURE_MTIME = 0xFFFFFFFF;
  516. constexpr auto CURRENT_MTIME = 1646057277;
  517. FakeFolder fakeFolder{FileInfo{}};
  518. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  519. const QString fooFileRootFolder("foo");
  520. const QString barFileRootFolder("bar");
  521. const QString fooFileSubFolder("subfolder/foo");
  522. const QString barFileSubFolder("subfolder/bar");
  523. const QString fooFileAaaSubFolder("aaa/subfolder/foo");
  524. const QString barFileAaaSubFolder("aaa/subfolder/bar");
  525. fakeFolder.remoteModifier().insert(fooFileRootFolder);
  526. fakeFolder.remoteModifier().insert(barFileRootFolder);
  527. fakeFolder.remoteModifier().mkdir(QStringLiteral("subfolder"));
  528. fakeFolder.remoteModifier().insert(fooFileSubFolder);
  529. fakeFolder.remoteModifier().insert(barFileSubFolder);
  530. fakeFolder.remoteModifier().mkdir(QStringLiteral("aaa"));
  531. fakeFolder.remoteModifier().mkdir(QStringLiteral("aaa/subfolder"));
  532. fakeFolder.remoteModifier().insert(fooFileAaaSubFolder);
  533. fakeFolder.remoteModifier().insert(barFileAaaSubFolder);
  534. QVERIFY(fakeFolder.syncOnce());
  535. fakeFolder.remoteModifier().setModTimeKeepEtag(fooFileRootFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  536. fakeFolder.remoteModifier().setModTimeKeepEtag(barFileRootFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  537. fakeFolder.remoteModifier().setModTimeKeepEtag(fooFileSubFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  538. fakeFolder.remoteModifier().setModTimeKeepEtag(barFileSubFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  539. fakeFolder.remoteModifier().setModTimeKeepEtag(fooFileAaaSubFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  540. fakeFolder.remoteModifier().setModTimeKeepEtag(barFileAaaSubFolder, QDateTime::fromSecsSinceEpoch(CURRENT_MTIME));
  541. fakeFolder.localModifier().setModTime(fooFileRootFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  542. fakeFolder.localModifier().setModTime(barFileRootFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  543. fakeFolder.localModifier().setModTime(fooFileSubFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  544. fakeFolder.localModifier().setModTime(barFileSubFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  545. fakeFolder.localModifier().setModTime(fooFileAaaSubFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  546. fakeFolder.localModifier().setModTime(barFileAaaSubFolder, QDateTime::fromSecsSinceEpoch(FUTURE_MTIME));
  547. QVERIFY(fakeFolder.syncOnce());
  548. QVERIFY(fakeFolder.syncOnce());
  549. auto expectedState = fakeFolder.currentLocalState();
  550. QCOMPARE(fakeFolder.currentRemoteState(), expectedState);
  551. }
  552. void testDiscoverLockChanges()
  553. {
  554. FakeFolder fakeFolder{FileInfo{}};
  555. fakeFolder.syncEngine().account()->setCapabilities({{"activity", QVariantMap{{"apiv2", QVariantList{"filters", "filters-api", "previews", "rich-strings"}}}},
  556. {"bruteforce", QVariantMap{{"delay", 0}}},
  557. {"core", QVariantMap{{"pollinterval", 60}, {"webdav-root", "remote.php/webdav"}}},
  558. {"dav", QVariantMap{{"chunking", "1.0"}}},
  559. {"files", QVariantMap{{"bigfilechunking", true}, {"blacklisted_files", QVariantList{".htaccess"}},
  560. {"comments", true},
  561. {"directEditing", QVariantMap{{"etag", "c748e8fc588b54fc5af38c4481a19d20"}, {"url", "https://nextcloud.local/ocs/v2.php/apps/files/api/v1/directEditing"}}},
  562. {"locking", "1.0"}}}});
  563. QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
  564. const QString fooFileRootFolder("foo");
  565. const QString barFileRootFolder("bar");
  566. const QString fooFileSubFolder("subfolder/foo");
  567. const QString barFileSubFolder("subfolder/bar");
  568. const QString fooFileAaaSubFolder("aaa/subfolder/foo");
  569. const QString barFileAaaSubFolder("aaa/subfolder/bar");
  570. fakeFolder.remoteModifier().insert(fooFileRootFolder);
  571. fakeFolder.remoteModifier().insert(barFileRootFolder);
  572. fakeFolder.remoteModifier().modifyLockState(QStringLiteral("bar"), FileInfo::LockState::FileLocked, 0, QStringLiteral("user1"), {}, QStringLiteral("user1"), 1648046707, 0);
  573. fakeFolder.remoteModifier().mkdir(QStringLiteral("subfolder"));
  574. fakeFolder.remoteModifier().insert(fooFileSubFolder);
  575. fakeFolder.remoteModifier().insert(barFileSubFolder);
  576. fakeFolder.remoteModifier().mkdir(QStringLiteral("aaa"));
  577. fakeFolder.remoteModifier().mkdir(QStringLiteral("aaa/subfolder"));
  578. fakeFolder.remoteModifier().insert(fooFileAaaSubFolder);
  579. fakeFolder.remoteModifier().insert(barFileAaaSubFolder);
  580. ItemCompletedSpy completeSpy(fakeFolder);
  581. completeSpy.clear();
  582. QVERIFY(fakeFolder.syncOnce());
  583. QCOMPARE(completeSpy.findItem("bar")->_locked, OCC::SyncFileItem::LockStatus::LockedItem);
  584. SyncJournalFileRecord fileRecordBefore;
  585. QVERIFY(fakeFolder.syncJournal().getFileRecord(QStringLiteral("bar"), &fileRecordBefore));
  586. QVERIFY(fileRecordBefore._lockstate._locked);
  587. fakeFolder.remoteModifier().modifyLockState(QStringLiteral("bar"), FileInfo::LockState::FileUnlocked, {}, {}, {}, {}, {}, {});
  588. fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem);
  589. completeSpy.clear();
  590. QVERIFY(fakeFolder.syncOnce());
  591. QCOMPARE(completeSpy.findItem("bar")->_locked, OCC::SyncFileItem::LockStatus::UnlockedItem);
  592. SyncJournalFileRecord fileRecordAfter;
  593. QVERIFY(fakeFolder.syncJournal().getFileRecord(QStringLiteral("bar"), &fileRecordAfter));
  594. QVERIFY(!fileRecordAfter._lockstate._locked);
  595. }
  596. };
  597. QTEST_GUILESS_MAIN(TestLocalDiscovery)
  598. #include "testlocaldiscovery.moc"