]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
SyncEngine: fixed restoring files when they are moved in a new directory
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 4 Apr 2016 08:41:12 +0000 (10:41 +0200)
committerOlivier Goffart <ogoffart@woboq.com>
Mon, 4 Apr 2016 08:41:12 +0000 (10:41 +0200)
Imagine tgus scenario on a read only share that you move file from
one location to a new directory in the read only share.
Creating the read only directory fails for permission error.
But we should also restore the files that have been moved.

IL issue 542

src/libsync/syncengine.cpp

index 97608447958727de25b2b05c236140dfcdc6131c..8a19fdc69c22e2185d32faecf86c5df7d6f0f65a 100644 (file)
@@ -1043,8 +1043,17 @@ void SyncEngine::checkForPermission()
                     (*it)->_status = SyncFileItem::NormalError;
                     (*it)->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder");
 
-                    for (SyncFileItemVector::iterator it_next = it + 1; it_next != _syncedItems.end() && (*it_next)->_file.startsWith(path); ++it_next) {
+                    for (SyncFileItemVector::iterator it_next = it + 1; it_next != _syncedItems.end() && (*it_next)->destination().startsWith(path); ++it_next) {
                         it = it_next;
+                        if ((*it)->_instruction == CSYNC_INSTRUCTION_RENAME) {
+                            // The file was most likely moved in this directory.
+                            // If the file was read only or could not be moved or removed, it should
+                            // be restored. Do that in the next sync by not considering as a rename
+                            // but delete and upload. It will then be restored if needed.
+                            _journal->avoidRenamesOnNextSync((*it)->_file);
+                            _anotherSyncNeeded = true;
+                            qDebug() << "Moving of " << (*it)->_file << " canceled because no permission to add parent folder";
+                        }
                         (*it)->_instruction = CSYNC_INSTRUCTION_ERROR;
                         (*it)->_status = SyncFileItem::NormalError;
                         (*it)->_errorString = tr("Not allowed because you don't have permission to add parent folder");