mirror of
https://github.com/etlegacy/Update-Installer.git
synced 2024-11-10 14:41:50 +00:00
Remove temporary updater files after update installation completes.
The cleanup is currently run in another process - on Windows for this to work the updater will need to be run from outside the temporary installation directory. Running the cleanup from the updater binary in the temporary directory will fail since the binary to be removed will then be in use. On Linux, Mac the cleanup could just be run from the main update installation process.
This commit is contained in:
parent
7c7428a4af
commit
be8d6cbc87
2 changed files with 34 additions and 8 deletions
|
@ -43,24 +43,40 @@ void UpdateInstaller::setScript(UpdateScript* script)
|
|||
m_script = script;
|
||||
}
|
||||
|
||||
void UpdateInstaller::run() throw ()
|
||||
std::list<std::string> UpdateInstaller::updaterArgs() const
|
||||
{
|
||||
if (m_mode == Setup)
|
||||
{
|
||||
LOG(Info,"Preparing update installation");
|
||||
LOG(Info,"Waiting for main app process to finish");
|
||||
ProcessUtils::waitForProcess(m_waitPid);
|
||||
|
||||
std::string updaterPath = ProcessUtils::currentProcessPath();
|
||||
std::list<std::string> args;
|
||||
args.push_back("--mode");
|
||||
args.push_back("main");
|
||||
args.push_back("--install-dir");
|
||||
args.push_back(m_installDir);
|
||||
args.push_back("--package-dir");
|
||||
args.push_back(m_packageDir);
|
||||
args.push_back("--script");
|
||||
args.push_back(m_script->path());
|
||||
return args;
|
||||
}
|
||||
|
||||
void UpdateInstaller::run() throw ()
|
||||
{
|
||||
std::string updaterPath;
|
||||
try
|
||||
{
|
||||
updaterPath = ProcessUtils::currentProcessPath();
|
||||
}
|
||||
catch (const FileOps::IOException& ex)
|
||||
{
|
||||
LOG(Error,"error reading process path with mode " + intToStr(m_mode));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_mode == Setup)
|
||||
{
|
||||
LOG(Info,"Preparing update installation");
|
||||
LOG(Info,"Waiting for main app process to finish");
|
||||
ProcessUtils::waitForProcess(m_waitPid);
|
||||
|
||||
std::list<std::string> args = updaterArgs();
|
||||
args.push_back("--mode");
|
||||
args.push_back("main");
|
||||
|
||||
if (!checkAccess())
|
||||
{
|
||||
|
@ -116,6 +132,11 @@ void UpdateInstaller::run() throw ()
|
|||
{
|
||||
m_observer->updateFinished();
|
||||
}
|
||||
|
||||
std::list<std::string> args = updaterArgs();
|
||||
args.push_back("--mode");
|
||||
args.push_back("cleanup");
|
||||
ProcessUtils::runAsync(updaterPath,args);
|
||||
}
|
||||
else if (m_mode == Cleanup)
|
||||
{
|
||||
|
@ -123,6 +144,8 @@ void UpdateInstaller::run() throw ()
|
|||
|
||||
ProcessUtils::waitForProcess(m_waitPid);
|
||||
cleanup();
|
||||
|
||||
LOG(Info,"Updater files removed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "UpdateScript.h"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
|
@ -40,6 +41,8 @@ class UpdateInstaller
|
|||
void installFile(const UpdateScriptFile& file);
|
||||
void backupFile(const std::string& path);
|
||||
|
||||
std::list<std::string> updaterArgs() const;
|
||||
|
||||
Mode m_mode;
|
||||
std::string m_installDir;
|
||||
std::string m_packageDir;
|
||||
|
|
Loading…
Reference in a new issue