diff --git a/CMakeLists.txt b/CMakeLists.txt index 853be4eb0..35561596f 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 8a19fdc69..aed09e5b1 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) {