From adba463f618678863e1c765362786a17a6def897 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 26 Aug 2011 13:13:11 +0100 Subject: [PATCH] Simplify cleanup of the updater's temporary directory Following the change to FileOps::removeFile() to support 'removal' of files that are in use in Windows, the cleanup of the updater's temporary directory can be performed from the non-elevated updater setup process once the main install process has returned. This removes the --mode cleanup run mode in the updater. --- src/UpdateInstaller.cpp | 33 ++++++++++----------------------- src/UpdateInstaller.h | 3 +-- src/UpdaterOptions.cpp | 8 -------- 3 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/UpdateInstaller.cpp b/src/UpdateInstaller.cpp index 143ef2e..13a161d 100644 --- a/src/UpdateInstaller.cpp +++ b/src/UpdateInstaller.cpp @@ -126,12 +126,7 @@ void UpdateInstaller::run() throw () restartMainApp(); // clean up files created by the updater - std::list cleanupArgs = updaterArgs(); - cleanupArgs.push_back("--mode"); - cleanupArgs.push_back("cleanup"); - cleanupArgs.push_back("--wait"); - cleanupArgs.push_back(intToStr(ProcessUtils::currentProcessId())); - ProcessUtils::runAsync(updaterPath,cleanupArgs); + cleanup(); } else if (m_mode == Main) { @@ -173,27 +168,19 @@ void UpdateInstaller::run() throw () m_observer->updateFinished(); } } - else if (m_mode == Cleanup) - { - LOG(Info,"Cleaning up temporary updater files"); - - ProcessUtils::waitForProcess(m_waitPid); - - try - { - cleanup(); - } - catch (const FileOps::IOException& ex) - { - LOG(Error,"Error cleaning up updater " + std::string(ex.what())); - } - LOG(Info,"Updater files removed"); - } } void UpdateInstaller::cleanup() { - FileOps::rmdirRecursive(m_packageDir.c_str()); + try + { + FileOps::rmdirRecursive(m_packageDir.c_str()); + } + catch (const FileOps::IOException& ex) + { + LOG(Error,"Error cleaning up updater " + std::string(ex.what())); + } + LOG(Info,"Updater files removed"); } void UpdateInstaller::revert() diff --git a/src/UpdateInstaller.h b/src/UpdateInstaller.h index 44bcf1b..3f08c61 100644 --- a/src/UpdateInstaller.h +++ b/src/UpdateInstaller.h @@ -15,8 +15,7 @@ class UpdateInstaller enum Mode { Setup, - Main, - Cleanup + Main }; UpdateInstaller(); diff --git a/src/UpdaterOptions.cpp b/src/UpdaterOptions.cpp index 7db077e..9611548 100644 --- a/src/UpdaterOptions.cpp +++ b/src/UpdaterOptions.cpp @@ -27,10 +27,6 @@ UpdateInstaller::Mode stringToMode(const std::string& modeStr) { return UpdateInstaller::Main; } - else if (modeStr == "cleanup") - { - return UpdateInstaller::Cleanup; - } else { if (!modeStr.empty()) @@ -84,10 +80,6 @@ void UpdaterOptions::parseOldFormatArgs(int argc, char** argv) { mode = UpdateInstaller::Main; } - else if (key == "--clean") - { - mode = UpdateInstaller::Cleanup; - } } }