owncloudcmd: return code depend on sync result
authorOlivier Goffart <ogoffart@woboq.com>
Fri, 31 Mar 2017 09:13:18 +0000 (11:13 +0200)
committerOlivier Goffart <olivier@woboq.com>
Thu, 13 Apr 2017 08:10:47 +0000 (10:10 +0200)
Issue #3936

src/cmd/cmd.cpp

index d4a9fc581c15ebcdf17ca7eb8c5cd3bc453525fa..5421b23143ba8e8d46aa215d1bdb45f1ab2e5e29 100644 (file)
@@ -478,7 +478,12 @@ restart_sync:
 
     SyncEngine engine(account, options.source_dir, folder, &db);
     engine.setIgnoreHiddenFiles(options.ignoreHiddenFiles);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+    QObject::connect(&engine, &SyncEngine::finished,
+                     [&app](bool result) { app.exit(result ? EXIT_SUCCESS : EXIT_FAILURE); });
+#else
     QObject::connect(&engine, SIGNAL(finished(bool)), &app, SLOT(quit()));
+#endif
     QObject::connect(&engine, SIGNAL(transmissionProgress(ProgressInfo)), &cmd, SLOT(transmissionProgressSlot()));
 
 
@@ -505,7 +510,7 @@ restart_sync:
     // Have to be done async, else, an error before exec() does not terminate the event loop.
     QMetaObject::invokeMethod(&engine, "startSync", Qt::QueuedConnection);
 
-    app.exec();
+    int resultCode = app.exec();
 
     if (engine.isAnotherSyncNeeded() != NoFollowUpSync) {
         if (restartCount < options.restartTimes) {
@@ -516,6 +521,6 @@ restart_sync:
         qWarning() << "Another sync is needed, but not done because restart count is exceeded" << restartCount;
     }
 
-    return 0;
+    return resultCode;
 }