diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 9712dabbd..668d09aeb 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -669,6 +669,11 @@ void Application::setupLogging() logger->setupTemporaryFolderLogDir(); } +#if defined QT_DEBUG + logger->setLogFlush(true); + logger->setLogDebug(true); +#endif + logger->enterNextLogFile(); qCInfo(lcApplication) << "##################" << _theme->appName() diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index c1732e13f..3278c450d 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -1,3 +1,5 @@ +#define OPENSSL_SUPPRESS_DEPRECATED + #include "clientsideencryption.h" #include diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index 342ccdd1b..1b2398c04 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -633,8 +633,9 @@ private slots: /** Emit the finished signal and make sure it is only emitted once */ void emitFinished(OCC::SyncFileItem::Status status) { - if (!_finishedEmited) - emit finished(status == SyncFileItem::Success); + if (!_finishedEmited) { + emit finished(status); + } _abortRequested = false; _finishedEmited = true; } @@ -645,7 +646,7 @@ signals: void newItem(const OCC::SyncFileItemPtr &); void itemCompleted(const SyncFileItemPtr &item, OCC::ErrorCategory category); void progress(const OCC::SyncFileItem &, qint64 bytes); - void finished(bool success); + void finished(OCC::SyncFileItem::Status status); /** Emitted when propagation has problems with a locked file. */ void seenLockedFile(const QString &fileName); diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 35f6d5913..d76c11eda 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -947,13 +947,13 @@ void SyncEngine::slotItemCompleted(const SyncFileItemPtr &item, const ErrorCateg emit itemCompleted(item, category); } -void SyncEngine::slotPropagationFinished(bool success) +void SyncEngine::slotPropagationFinished(OCC::SyncFileItem::Status status) { if (_propagator->_anotherSyncNeeded && _anotherSyncNeeded == NoFollowUpSync) { _anotherSyncNeeded = ImmediateFollowUp; } - if (success && _discoveryPhase) { + if ((status == SyncFileItem::Success || status == SyncFileItem::BlacklistedError) && _discoveryPhase) { _journal->setDataFingerprint(_discoveryPhase->_dataFingerprint); } @@ -970,7 +970,7 @@ void SyncEngine::slotPropagationFinished(bool success) _progressInfo->_status = ProgressInfo::Done; emit transmissionProgress(*_progressInfo); - finalize(success); + finalize(status == SyncFileItem::Success); } void SyncEngine::finalize(bool success) @@ -1036,8 +1036,9 @@ void SyncEngine::restoreOldFiles(SyncFileItemVector &syncItems) */ for (const auto &syncItem : qAsConst(syncItems)) { - if (syncItem->_direction != SyncFileItem::Down) + if (syncItem->_direction != SyncFileItem::Down || syncItem->_isSelectiveSync) { continue; + } switch (syncItem->_instruction) { case CSYNC_INSTRUCTION_SYNC: diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index d1c4ab9d5..2a60cba2d 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -212,7 +212,7 @@ private slots: void slotItemCompleted(const OCC::SyncFileItemPtr &item, const OCC::ErrorCategory category); void slotDiscoveryFinished(); - void slotPropagationFinished(bool success); + void slotPropagationFinished(SyncFileItem::Status status); void slotProgress(const OCC::SyncFileItem &item, qint64 current); void slotCleanPollsJobAborted(const QString &error, const OCC::ErrorCategory category); diff --git a/test/testselectivesync.cpp b/test/testselectivesync.cpp index 7aa33feb5..d12a2e40d 100644 --- a/test/testselectivesync.cpp +++ b/test/testselectivesync.cpp @@ -17,7 +17,11 @@ class TestSelectiveSync : public QObject Q_OBJECT private slots: - + void initTestCase() + { + Logger::instance()->setLogFlush(true); + Logger::instance()->setLogDebug(true); + } void testSelectiveSyncBigFolders() { @@ -86,6 +90,38 @@ private slots: QCOMPARE(sizeRequests.count(), 0); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); } + + void testRestoreSubFolderForDataFingerPrint() + { + const auto mkcolVerb = QByteArray{"MKCOL"}; + FakeFolder fakeFolder{{}}; + fakeFolder.localModifier().mkdir("topFolder"); + fakeFolder.localModifier().mkdir("topFolder/subFolder"); + fakeFolder.localModifier().insert("topFolder/subFolder/a"); + fakeFolder.remoteModifier().extraDavProperties = "initial_finger_print"; + + QVERIFY(fakeFolder.syncOnce()); + + auto mkdirRequestsCounter = 0; + fakeFolder.setServerOverride([&mkdirRequestsCounter, mkcolVerb](QNetworkAccessManager::Operation, const QNetworkRequest &req, QIODevice *device) + -> QNetworkReply * { + Q_UNUSED(device) + + if (req.attribute(QNetworkRequest::CustomVerbAttribute) == mkcolVerb) { + ++mkdirRequestsCounter; + } + qDebug() << req.attribute(QNetworkRequest::CustomVerbAttribute); + + return nullptr; + }); + + fakeFolder.syncEngine().journal()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, + QStringList() << QLatin1String("topFolder")); + fakeFolder.remoteModifier().extraDavProperties = "changed_finger_print"; + + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(mkdirRequestsCounter, 0); + } }; QTEST_GUILESS_MAIN(TestSelectiveSync)