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();
// clean up files created by the updater
std::list<std::string> 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,15 +168,13 @@ void UpdateInstaller::run() throw ()
m_observer->updateFinished();
}
}
else if (m_mode == Cleanup)
}
void UpdateInstaller::cleanup()
{
LOG(Info,"Cleaning up temporary updater files");
ProcessUtils::waitForProcess(m_waitPid);
try
{
cleanup();
FileOps::rmdirRecursive(m_packageDir.c_str());
}
catch (const FileOps::IOException& ex)
{
@ -189,12 +182,6 @@ void UpdateInstaller::run() throw ()
}
LOG(Info,"Updater files removed");
}
}
void UpdateInstaller::cleanup()
{
FileOps::rmdirRecursive(m_packageDir.c_str());
}
void UpdateInstaller::revert()
{

View file

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

View file

@ -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;
}
}
}