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.
This commit is contained in:
Robert Knight 2011-08-26 13:13:11 +01:00
parent ef6809e0fe
commit adba463f61
3 changed files with 11 additions and 33 deletions

View file

@ -126,12 +126,7 @@ void UpdateInstaller::run() throw ()
restartMainApp(); restartMainApp();
// clean up files created by the updater // clean up files created by the updater
std::list<std::string> cleanupArgs = updaterArgs(); cleanup();
cleanupArgs.push_back("--mode");
cleanupArgs.push_back("cleanup");
cleanupArgs.push_back("--wait");
cleanupArgs.push_back(intToStr(ProcessUtils::currentProcessId()));
ProcessUtils::runAsync(updaterPath,cleanupArgs);
} }
else if (m_mode == Main) else if (m_mode == Main)
{ {
@ -173,27 +168,19 @@ void UpdateInstaller::run() throw ()
m_observer->updateFinished(); 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() 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() void UpdateInstaller::revert()

View file

@ -15,8 +15,7 @@ class UpdateInstaller
enum Mode enum Mode
{ {
Setup, Setup,
Main, Main
Cleanup
}; };
UpdateInstaller(); UpdateInstaller();

View file

@ -27,10 +27,6 @@ UpdateInstaller::Mode stringToMode(const std::string& modeStr)
{ {
return UpdateInstaller::Main; return UpdateInstaller::Main;
} }
else if (modeStr == "cleanup")
{
return UpdateInstaller::Cleanup;
}
else else
{ {
if (!modeStr.empty()) if (!modeStr.empty())
@ -84,10 +80,6 @@ void UpdaterOptions::parseOldFormatArgs(int argc, char** argv)
{ {
mode = UpdateInstaller::Main; mode = UpdateInstaller::Main;
} }
else if (key == "--clean")
{
mode = UpdateInstaller::Cleanup;
}
} }
} }