mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 13:05:51 +03:00
Merge pull request #6134 from nextcloud/bugfix/restoreFoldersRecursively
Bugfix/restore folders recursively
This commit is contained in:
commit
ab5984549c
6 changed files with 54 additions and 9 deletions
|
@ -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()
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#define OPENSSL_SUPPRESS_DEPRECATED
|
||||
|
||||
#include "clientsideencryption.h"
|
||||
|
||||
#include <openssl/rsa.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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 = "<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)
|
||||
|
|
Loading…
Reference in a new issue