From 00fae05507359082a48f601da00f9ae697de6827 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Tue, 17 Nov 2015 22:39:59 +0200 Subject: [PATCH] Don't ask the user questions in nox build when in non-interactive mode. Closes #3875. --- src/app/main.cpp | 14 ++++++++++++++ src/app/upgrade.h | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 36a440e1f..e14bff9cb 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -181,8 +181,16 @@ int main(int argc, char *argv[]) if (!qputenv("QBITTORRENT", QByteArray(VERSION))) std::cerr << "Couldn't set environment variable...\n"; +#ifndef DISABLE_GUI if (!userAgreesWithLegalNotice()) return EXIT_SUCCESS; +#else + if (!params.shouldDaemonize + && isatty(fileno(stdin)) + && isatty(fileno(stdout)) + && !userAgreesWithLegalNotice()) + return EXIT_SUCCESS; +#endif // Check if qBittorrent is already running for this user if (app->isRunning()) { @@ -202,7 +210,13 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } +#ifndef DISABLE_GUI if (!upgrade()) return EXIT_FAILURE; +#else + if (!upgrade(!params.shouldDaemonize + && isatty(fileno(stdin)) + && isatty(fileno(stdout)))) return EXIT_FAILURE; +#endif srand(time(0)); #ifdef DISABLE_GUI diff --git a/src/app/upgrade.h b/src/app/upgrade.h index 49c9f8afc..28ce24e8a 100644 --- a/src/app/upgrade.h +++ b/src/app/upgrade.h @@ -104,7 +104,7 @@ bool upgradeResumeFile(const QString &filepath) return false; } -bool upgrade() +bool upgrade(bool ask = true) { QString backupFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + "BT_backup"); QDir backupFolderDir(backupFolderPath); @@ -112,7 +112,7 @@ bool upgrade() QStringList backupFiles = backupFolderDir.entryList(QStringList() << QLatin1String("*.fastresume"), QDir::Files, QDir::Unsorted); if (!backupFiles.isEmpty()) { - if (!userAcceptsUpgrade()) return false; + if (ask && !userAcceptsUpgrade()) return false; QRegExp rx(QLatin1String("^([A-Fa-f0-9]{40})\\.fastresume$")); foreach (QString backupFile, backupFiles) {