Просмотр исходного кода

owncloudcmd: Do not overwrite the http timeout for json jobs

The AbstractNetworkJob already has a sensible timeout that depends
on an environment variable.
No need to overwrite that with some arbitrary value. (The connection
validator does that because it could cause problems if two connection
validator were to run at the same time. Not a problem here)
Olivier Goffart 8 лет назад
Родитель
Сommit
7e05e1e411
1 измененных файлов с 23 добавлено и 21 удалено
  1. 23 21
      src/cmd/cmd.cpp

+ 23 - 21
src/cmd/cmd.cpp

@@ -33,7 +33,6 @@
 #include "syncengine.h"
 #include "common/syncjournaldb.h"
 #include "config.h"
-#include "connectionvalidator.h"
 
 #include "cmd.h"
 
@@ -83,8 +82,6 @@ struct CmdOptions
 // So we have to use a global variable
 CmdOptions *opts = 0;
 
-const qint64 timeoutToUseMsec = qMax(1000, ConnectionValidator::DefaultCallingIntervalMsec - 5 * 1000);
-
 class EchoDisabler
 {
 public:
@@ -451,24 +448,29 @@ int main(int argc, char **argv)
     account->setCredentials(cred);
     account->setSslErrorHandler(sslErrorHandler);
 
-    //obtain capabilities using event loop
-    QEventLoop loop;
-
-    JsonApiJob *job = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/capabilities"));
-    job->setTimeout(timeoutToUseMsec);
-    QObject::connect(job, &JsonApiJob::jsonReceived, [&](const QJsonDocument &json) {
-        auto caps = json.object().value("ocs").toObject().value("data").toObject().value("capabilities").toObject();
-        qDebug() << "Server capabilities" << caps;
-        account->setCapabilities(caps.toVariantMap());
-        loop.quit();
-    });
-    job->start();
-
-    loop.exec();
-
-    if (job->reply()->error() != QNetworkReply::NoError){
-        std::cout<<"Error connecting to server\n";
-        return EXIT_FAILURE;
+    // Perform a call to get the capabilities.
+    if (!options.nonShib) {
+        // Do not do it if '--nonshib' was passed. This mean we should only connect to the 'nonshib'
+        // dav endpoint. Since we do not get the capabilities, in that case, this has the additional
+        // side effect that chunking-ng will be disabled. (because otherwise it would use the new
+        // 'dav' endpoint instead of the nonshib one (which still use the old chunking)
+
+        QEventLoop loop;
+        JsonApiJob *job = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/capabilities"));
+        QObject::connect(job, &JsonApiJob::jsonReceived, [&](const QJsonDocument &json) {
+            auto caps = json.object().value("ocs").toObject().value("data").toObject().value("capabilities").toObject();
+            qDebug() << "Server capabilities" << caps;
+            account->setCapabilities(caps.toVariantMap());
+            loop.quit();
+        });
+        job->start();
+
+        loop.exec();
+
+        if (job->reply()->error() != QNetworkReply::NoError){
+            std::cout<<"Error connecting to server\n";
+            return EXIT_FAILURE;
+        }
     }
 
     // much lower age than the default since this utility is usually made to be run right after a change in the tests