New discovery algorithm: Fix directory deletion
authorOlivier Goffart <ogoffart@woboq.com>
Tue, 17 Jul 2018 08:09:57 +0000 (10:09 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:57:59 +0000 (10:57 +0100)
TestAllFilesDeleted passes

src/libsync/discovery.h
src/libsync/syncengine.cpp

index 727c44b2345cf034d1e8ea842b3d4f212d6571d5..79b244317d5968398a23f5ca697e42424805e739 100644 (file)
@@ -85,6 +85,8 @@ public:
     void start();
     void abort();
 
+    SyncFileItemPtr _dirItem;
+
 private:
     struct PathTuple
     {
@@ -121,7 +123,6 @@ private:
     QPointer<DiscoverServerJob> _serverJob;
     std::deque<ProcessDirectoryJob *> _queuedJobs;
     QVector<ProcessDirectoryJob *> _runningJobs;
-    SyncFileItemPtr _dirItem;
     QueryMode _queryServer;
     QueryMode _queryLocal;
     DiscoveryPhase *_discoveryData;
index 56130442e5929fc018fe009f4ee64d3919eca62f..74d1c82ca79ab8a5b13c7860257e68568b549d5b 100644 (file)
@@ -925,7 +925,9 @@ void SyncEngine::slotStartDiscovery()
         _discoveryPhase.data(), this);
     // FIXME! this sucks
     auto runQueuedJob = [this](ProcessDirectoryJob *job, const auto &runQueuedJob) -> void {
-        connect(job, &ProcessDirectoryJob::finished, this, [this, runQueuedJob] {
+        connect(job, &ProcessDirectoryJob::finished, this, [this, job, runQueuedJob] {
+            if (job->_dirItem)
+                job->itemDiscovered(job->_dirItem);
             sender()->deleteLater();
             if (!_discoveryPhase->_queuedDeletedDirectories.isEmpty()) {
                 auto job = qobject_cast<ProcessDirectoryJob *>(_discoveryPhase->_queuedDeletedDirectories.take(_discoveryPhase->_queuedDeletedDirectories.firstKey()).data());
@@ -1012,18 +1014,11 @@ void SyncEngine::slotDiscoveryJobFinished()
 
     //    qCInfo(lcEngine) << "Permissions of the root folder: " << _csync_ctx->remote.root_perms.toString();
 
-    /*
-
-    // Adjust the paths for the renames.
-    for (const auto &syncItem : qAsConst(syncItems)) {
-        syncItem->_file = adjustRenamedPath(syncItem->_file);
-    }
-
     ConfigFile cfgFile;
     if (!_hasNoneFiles && _hasRemoveFile && cfgFile.promptDeleteFiles()) {
         qCInfo(lcEngine) << "All the files are going to be changed, asking the user";
         bool cancel = false;
-        emit aboutToRemoveAllFiles(syncItems.first()->_direction, &cancel);
+        emit aboutToRemoveAllFiles(_syncItems.first()->_direction, &cancel);
         if (cancel) {
             qCInfo(lcEngine) << "User aborted sync";
             finalize(false);
@@ -1031,6 +1026,7 @@ void SyncEngine::slotDiscoveryJobFinished()
         }
     }
 
+    /*
     auto databaseFingerprint = _journal->dataFingerprint();
     // If databaseFingerprint is empty, this means that there was no information in the database
     // (for example, upgrading from a previous version, or first sync, or server not supporting fingerprint)