[Pkg-owncloud-commits] [owncloud-client] 11/78: SyncEngine: Add a compile option so we rename to restoring a move we don't have the permission to do

Sandro Knauß hefee-guest at moszumanska.debian.org
Fri Jun 24 16:29:37 UTC 2016


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 5676685f5845b317745d6ff8e7561537c9414a13
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Thu May 12 13:14:07 2016 +0200

    SyncEngine: Add a compile option so we rename to restoring a move we don't have the permission to do
    
    IL issue 550
---
 CMakeLists.txt             | 12 ++++++++++++
 src/libsync/syncengine.cpp |  9 ++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 853be4e..3556159 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,4 @@
+
 cmake_minimum_required(VERSION 2.6)
 cmake_policy(VERSION 2.8.0)
 
@@ -122,6 +123,17 @@ if(OWNCLOUD_5XX_NO_BLACKLIST)
     add_definitions(-DOWNCLOUD_5XX_NO_BLACKLIST=1)
 endif()
 
+# When this option is enabled, a rename that is not allowed will be renamed back
+# do the original as a restoration step.  Withut this option, the restoration will
+# re-download the file instead.
+# The default is off because we don't want to rename the files back behind the user's back
+# Added for IL issue #550
+option(OWNCLOUD_RESTORE_RENAME "OWNCLOUD_RESTORE_RENAME" OFF)
+if(OWNCLOUD_RESTORE_RENAME)
+    add_definitions(-DOWNCLOUD_RESTORE_RENAME=1)
+endif()
+
+
 if(APPLE)
   set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
 endif()
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 8a19fdc..aed09e5 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -1182,15 +1182,18 @@ void SyncEngine::checkForPermission()
                     }
                 }
 
-#if 0 /* We don't like the idea of renaming behind user's back, as the user may be working with the files */
-
-                if (!sourceOK && !destinationOK) {
+#ifdef OWNCLOUD_RESTORE_RENAME /* We don't like the idea of renaming behind user's back, as the user may be working with the files */
+                if (!sourceOK && (!destinationOK || isRename)
+                        // (not for directory because that's more complicated with the contents that needs to be adjusted)
+                        && !(*it)->_isDirectory) {
                     // Both the source and the destination won't allow move.  Move back to the original
                     std::swap((*it)->_file, (*it)->_renameTarget);
                     (*it)->_direction = SyncFileItem::Down;
                     (*it)->_errorString = tr("Move not allowed, item restored");
                     (*it)->_isRestoration = true;
                     qDebug() << "checkForPermission: MOVING BACK" << (*it)->_file;
+                    // in case something does wrong, we will not do it next time
+                    _journal->avoidRenamesOnNextSync((*it)->_file);
                 } else
 #endif
                 if (!sourceOK || !destinationOK) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list