diff options
| author | Chris Bessent <lost.dragonist@gmail.com> | 2020-09-06 06:57:05 -0700 |
|---|---|---|
| committer | Chris Bessent <lost.dragonist@gmail.com> | 2020-09-06 06:57:05 -0700 |
| commit | 23eab916aeefb773409d2c9dcb3ea2cd2ee1bda9 (patch) | |
| tree | bbc50427d1cbe3ceb9c6a8c52cac88e965241250 /src | |
| parent | 2ad41ee2cd94f5012140989f9ddc553459fc5214 (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/installationmanager.cpp | 21 | ||||
| -rw-r--r-- | src/installationmanager.h | 2 |
2 files changed, 13 insertions, 10 deletions
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<QString> &modName, bool *merge) +IPluginInstaller::EInstallResult InstallationManager::testOverwrite(GuessedValue<QString> &modName, bool *merge) { QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory + "\\" + modName); @@ -388,7 +388,7 @@ bool InstallationManager::testOverwrite(GuessedValue<QString> &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<QString> &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<QString> &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<QSt bool merge = false; // determine target directory - if (!testOverwrite(modName, &merge)) { - return IPluginInstaller::RESULT_FAILED; + IPluginInstaller::EInstallResult result = testOverwrite(modName, &merge); + if (result != IPluginInstaller::RESULT_SUCCESS) { + return result; } QString targetDirectory = QDir(m_ModsDirectory + "/" + modName).canonicalPath(); diff --git a/src/installationmanager.h b/src/installationmanager.h index b3a7362f..63e8794e 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -185,7 +185,7 @@ public: * @param merge if this value is not null, the value will be set to whether the use chose to merge or replace * @return true if we can proceed with the installation, false if the user canceled or in case of an unrecoverable error */ - virtual bool testOverwrite(MOBase::GuessedValue<QString> &modName, bool *merge = nullptr); + virtual MOBase::IPluginInstaller::EInstallResult testOverwrite(MOBase::GuessedValue<QString> &modName, bool *merge = nullptr); QString generateBackupName(const QString &directoryName) const; |
