SyncEngine: For server older than 8.1, ignore invalid char in new directories
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 13 Jan 2016 16:49:41 +0000 (17:49 +0100)
committerOlivier Goffart <ogoffart@woboq.com>
Wed, 13 Jan 2016 16:53:12 +0000 (17:53 +0100)
Server older than 8.1 cannot cope with invalid char in the filename
so we must not send them from the client. We were already checking
for new files, but not for renames or new directories.

https://github.com/owncloud/enterprise/issues/1009

src/libsync/propagateupload.cpp
src/libsync/syncengine.cpp

index e468f8791f2f1f1a0f019b7beb1dbe6b43e390b5..ff6c1dad69d1849381cf68616d50c8ed5361ff0a 100644 (file)
@@ -199,16 +199,6 @@ void PropagateUploadFileQNAM::start()
         return;
     }
 
-    if (_propagator->account()->serverVersionInt() < 0x080100) {
-        // Server version older than 8.1 don't support these character in filename.
-        static const QRegExp invalidCharRx("[\\\\:?*\"<>|]");
-        if (_item->_file.contains(invalidCharRx)) {
-            _item->_httpErrorCode = 400; // So the entry get blacklisted
-            done(SyncFileItem::NormalError, tr("File name contains at least one invalid character"));
-            return;
-        }
-    }
-
     _propagator->_activeJobs++;
 
     if (!_deleteExisting) {
index 6be3e93b3c9e9e5a95d1a2429ff5430e243b1f72..301c0fb5a4812ab7521429066f1ff91e4ebe0f2f 100644 (file)
@@ -816,6 +816,19 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
         (*it)->_file = adjustRenamedPath((*it)->_file);
     }
 
+    // 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;
+            }
+        }
+    }
+
     // Sort items per destination
     std::sort(_syncedItems.begin(), _syncedItems.end());