Propagator: Keep a meaningfull error with old server and invalid file names
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 28 Oct 2015 12:25:49 +0000 (13:25 +0100)
committerOlivier Goffart <ogoffart@woboq.com>
Thu, 29 Oct 2015 11:44:08 +0000 (12:44 +0100)
We changed the discovery code not to ignore files whose filename contains
charachter invalid on windows. (Because newer versions of the server
supports them)
Servers older than 8.1 will just say "Bad Request" as an error and it's a
regression against previous client version. So keep nice error even with
older server.

Relates to #3736

src/libsync/propagateupload.cpp

index 59ab268ab97ac04b2649676990747741863609f0..0a4c411c3797e9367f332a55b6d9c41219d32e69 100644 (file)
@@ -197,6 +197,16 @@ 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;
+        }
+    }
+
     const QString filePath = _propagator->getFilePath(_item->_file);
 
     // remember the modtime before checksumming to be able to detect a file