From 23eab916aeefb773409d2c9dcb3ea2cd2ee1bda9 Mon Sep 17 00:00:00 2001 From: Chris Bessent Date: Sun, 6 Sep 2020 06:57:05 -0700 Subject: Do not report a canceled install as failed When a mod install reached the point of checking for overwrites with existing mods (i.e., new mod has the same name as an old mod), there was no way to distinguish between a failure and a user cancellation. Now, an explicit status is passed up the stack so the cancellation can be safely ignored by error checking code. --- src/installationmanager.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/installationmanager.cpp') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 801b2a67..608a8c91 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -369,7 +369,7 @@ QString InstallationManager::generateBackupName(const QString &directoryName) co } -bool InstallationManager::testOverwrite(GuessedValue &modName, bool *merge) +IPluginInstaller::EInstallResult InstallationManager::testOverwrite(GuessedValue &modName, bool *merge) { QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory + "\\" + modName); @@ -388,7 +388,7 @@ bool InstallationManager::testOverwrite(GuessedValue &modName, bool *me QString backupDirectory = generateBackupName(targetDirectory); if (!copyDir(targetDirectory, backupDirectory, false)) { reportError(tr("Failed to create backup")); - return false; + return IPluginInstaller::RESULT_FAILED; } } if (merge != nullptr) { @@ -401,7 +401,7 @@ bool InstallationManager::testOverwrite(GuessedValue &modName, bool *me if (ok && !name.isEmpty()) { modName.update(name, GUESS_USER); if (!ensureValidModName(modName)) { - return false; + return IPluginInstaller::RESULT_FAILED; } targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory) + "/" + modName; } @@ -436,18 +436,20 @@ bool InstallationManager::testOverwrite(GuessedValue &modName, bool *me } else { log::error("failed to restore original settings: {}", metaFilename); } - return true; + return IPluginInstaller::RESULT_SUCCESS; } else if (overwriteDialog.action() == QueryOverwriteDialog::ACT_MERGE) { - return true; + return IPluginInstaller::RESULT_SUCCESS; + } else /* if (overwriteDialog.action() == QueryOverwriteDialog::ACT_NONE) */ { + return IPluginInstaller::RESULT_CANCELED; } } else { - return false; + return IPluginInstaller::RESULT_CANCELED; } } QDir().mkdir(targetDirectory); - return true; + return IPluginInstaller::RESULT_SUCCESS;; } @@ -476,8 +478,9 @@ IPluginInstaller::EInstallResult InstallationManager::doInstall(GuessedValue