Browse Source

Don't ask the user questions in nox build when in non-interactive mode. Closes #3875.

adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
00fae05507
  1. 14
      src/app/main.cpp
  2. 4
      src/app/upgrade.h

14
src/app/main.cpp

@ -181,8 +181,16 @@ int main(int argc, char *argv[])
if (!qputenv("QBITTORRENT", QByteArray(VERSION))) if (!qputenv("QBITTORRENT", QByteArray(VERSION)))
std::cerr << "Couldn't set environment variable...\n"; std::cerr << "Couldn't set environment variable...\n";
#ifndef DISABLE_GUI
if (!userAgreesWithLegalNotice()) if (!userAgreesWithLegalNotice())
return EXIT_SUCCESS; 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 // Check if qBittorrent is already running for this user
if (app->isRunning()) { if (app->isRunning()) {
@ -202,7 +210,13 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
#ifndef DISABLE_GUI
if (!upgrade()) return EXIT_FAILURE; if (!upgrade()) return EXIT_FAILURE;
#else
if (!upgrade(!params.shouldDaemonize
&& isatty(fileno(stdin))
&& isatty(fileno(stdout)))) return EXIT_FAILURE;
#endif
srand(time(0)); srand(time(0));
#ifdef DISABLE_GUI #ifdef DISABLE_GUI

4
src/app/upgrade.h

@ -104,7 +104,7 @@ bool upgradeResumeFile(const QString &filepath)
return false; return false;
} }
bool upgrade() bool upgrade(bool ask = true)
{ {
QString backupFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + "BT_backup"); QString backupFolderPath = Utils::Fs::expandPathAbs(Utils::Fs::QDesktopServicesDataLocation() + "BT_backup");
QDir backupFolderDir(backupFolderPath); QDir backupFolderDir(backupFolderPath);
@ -112,7 +112,7 @@ bool upgrade()
QStringList backupFiles = backupFolderDir.entryList(QStringList() << QLatin1String("*.fastresume"), QDir::Files, QDir::Unsorted); QStringList backupFiles = backupFolderDir.entryList(QStringList() << QLatin1String("*.fastresume"), QDir::Files, QDir::Unsorted);
if (!backupFiles.isEmpty()) { if (!backupFiles.isEmpty()) {
if (!userAcceptsUpgrade()) return false; if (ask && !userAcceptsUpgrade()) return false;
QRegExp rx(QLatin1String("^([A-Fa-f0-9]{40})\\.fastresume$")); QRegExp rx(QLatin1String("^([A-Fa-f0-9]{40})\\.fastresume$"));
foreach (QString backupFile, backupFiles) { foreach (QString backupFile, backupFiles) {

Loading…
Cancel
Save