Merge pull request #4389 from Bottswana/deleteprompt
authorMarkus Goetz <markus@woboq.com>
Mon, 22 Feb 2016 14:44:50 +0000 (15:44 +0100)
committerMarkus Goetz <markus@woboq.com>
Mon, 22 Feb 2016 14:44:50 +0000 (15:44 +0100)
Add option to disable the delete all files prompt

1  2 
src/libsync/configfile.cpp
src/libsync/configfile.h
src/libsync/syncengine.cpp

Simple merge
Simple merge
index ac3b3ea086e57f2449c5c6601ec528c493ebbc7e,4a7c73805bb91ca85385d20234fccf4b512287b9..8f4f2c03cd376a93ec38f19417a9d7ea4cfca9d5
@@@ -828,20 -813,21 +829,22 @@@ void SyncEngine::slotDiscoveryJobFinish
          (*it)->_file = adjustRenamedPath((*it)->_file);
      }
  
 -    // Sort items per destination
 -    std::sort(_syncedItems.begin(), _syncedItems.end());
 -
 -    // make sure everything is allowed
 -    checkForPermission();
 -
 -    // To announce the beginning of the sync
 -    emit aboutToPropagate(_syncedItems);
 -    // it's important to do this before ProgressInfo::start(), to announce start of new sync
 -    emit transmissionProgress(*_progressInfo);
 -    _progressInfo->start();
 +    // Check for invalid character in old server version
 +    if (_account->serverVersionInt() < 0x080100) {
 +        // Server version older than 8.1 don't support these character in filename.
 +        static const QRegExp invalidCharRx("[\\\\:?*\"<>|]");
 +        for (auto it = _syncedItems.begin(); it != _syncedItems.end(); ++it) {
 +            if ((*it)->_direction == SyncFileItem::Up &&
 +                    (*it)->destination().contains(invalidCharRx)) {
 +                (*it)->_errorString  = tr("File name contains at least one invalid character");
 +                (*it)->_instruction = CSYNC_INSTRUCTION_IGNORE;
 +            }
 +        }
 +    }
  
-     if (!_hasNoneFiles && _hasRemoveFile) {
+     // Check the config file before displaying prompt in case it is disabled.
+     ConfigFile cfgFile;
+     if (!_hasNoneFiles && _hasRemoveFile && cfgFile.promptDeleteFiles()) {
          qDebug() << Q_FUNC_INFO << "All the files are going to be changed, asking the user";
          bool cancel = false;
          emit aboutToRemoveAllFiles(_syncedItems.first()->_direction, &cancel);