Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.10] Bugfix/restore folders recursively #6143

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/clientsideencryption.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define OPENSSL_SUPPRESS_DEPRECATED

#include "clientsideencryption.h"

#include <openssl/rsa.h>
Expand Down
7 changes: 4 additions & 3 deletions src/libsync/owncloudpropagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -645,7 +646,7 @@ private slots:
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);
Expand Down
9 changes: 5 additions & 4 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/syncengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
38 changes: 37 additions & 1 deletion test/testselectivesync.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in test/testselectivesync.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on test/testselectivesync.cpp

File test/testselectivesync.cpp (lines 106, 107, 108, 110, 111, 112, 113, 115, 118): Code does not conform to Custom style guidelines.
* This software is in the public domain, furnished "as is", without technical
* support, and with no warranty, express or implied, as to its usefulness for
* any purpose.
Expand All @@ -17,7 +17,11 @@
Q_OBJECT

private slots:

void initTestCase()
{
Logger::instance()->setLogFlush(true);
Logger::instance()->setLogDebug(true);
}

void testSelectiveSyncBigFolders()
{
Expand Down Expand Up @@ -86,6 +90,38 @@
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 = "<oc:data-fingerprint>initial_finger_print</oc:data-fingerprint>";

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 = "<oc:data-fingerprint>changed_finger_print</oc:data-fingerprint>";

QVERIFY(fakeFolder.syncOnce());
QCOMPARE(mkdirRequestsCounter, 0);
}
};

QTEST_GUILESS_MAIN(TestSelectiveSync)
Expand Down
Loading