]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
SyncEngine: Fix renaming of folder when file are changed (#5195)
authorOlivier Goffart <olivier@woboq.com>
Thu, 22 Sep 2016 07:02:47 +0000 (09:02 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Thu, 22 Sep 2016 07:05:09 +0000 (09:05 +0200)
Two bugs:
 - The change filed are not considered as move, they are re-downloaded
   but the old file was not removed from the database. The change in
   owncloudpropagator.cpp takes care of removing the old entries.

 - Next sync would then remove the file in the server in the old folder
   This was not a problem until we start reusing the sync engine, and
   that the _renamedFolders map is not cleared. We were before deleting
   a non-existing file. But now we delete the actual file.

Also improve the tests to be able to do move on the server.
This include support for file id.

Issue #5192
(cherry picked from commit 85b8ab178e21cf4dcaf792f68c15e55f6e0ee3c2)

src/libsync/owncloudpropagator.cpp
src/libsync/syncengine.cpp

index 72046fccf4cde943af49c2058700ed78633195ad..998160c1cedf642486926e75a1dd7a4983eea7c1 100644 (file)
@@ -695,6 +695,12 @@ void PropagateDirectory::finalize()
     bool ok = true;
     if (!_item->isEmpty() && _hasError == SyncFileItem::NoStatus) {
         if( !_item->_renameTarget.isEmpty() ) {
+            if(_item->_instruction == CSYNC_INSTRUCTION_RENAME
+                    && _item->_originalFile != _item->_renameTarget) {
+                // Remove the stale entries from the database.
+                _propagator->_journal->deleteFileRecord(_item->_originalFile, true);
+            }
+
             _item->_file = _item->_renameTarget;
         }
 
index a9f9701de333ef17691a16aa8945ed2da239ec48..636ffb1c8f91bf1c14bf7959be589360ff142f73 100644 (file)
@@ -856,6 +856,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
     bool walkOk = true;
     _seenFiles.clear();
     _temporarilyUnavailablePaths.clear();
+    _renamedFolders.clear();
 
     if( csync_walk_local_tree(_csync_ctx, &treewalkLocal, 0) < 0 ) {
         qDebug() << "Error in local treewalk.";