mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Clean up after ourselves after initial install
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "unzip.h"
|
||||
#include "Resource.h"
|
||||
#include "UpdateRunner.h"
|
||||
#include <vector>
|
||||
|
||||
void CUpdateRunner::DisplayErrorMessage(CString& errorMessage, wchar_t* logFile)
|
||||
{
|
||||
@@ -36,6 +37,7 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine)
|
||||
CResource zipResource;
|
||||
wchar_t targetDir[MAX_PATH];
|
||||
wchar_t logFile[MAX_PATH];
|
||||
std::vector<CString> to_delete;
|
||||
|
||||
ExpandEnvironmentStrings(L"%LocalAppData%\\SquirrelTemp", targetDir, _countof(targetDir));
|
||||
if (!CreateDirectory(targetDir, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||
@@ -74,6 +76,7 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine)
|
||||
DeleteFile(targetFile);
|
||||
|
||||
if (UnzipItem(zipFile, index, zentry.name) != ZR_OK) break;
|
||||
to_delete.push_back(CString(targetFile));
|
||||
index++;
|
||||
} while (zr == ZR_MORE || zr == ZR_OK);
|
||||
|
||||
@@ -116,6 +119,10 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine)
|
||||
L"Check the setup log for more information and contact the author."), logFile);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < to_delete.size(); i++) {
|
||||
DeleteFile(to_delete[i]);
|
||||
}
|
||||
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
return (int) dwExitCode;
|
||||
|
||||
Reference in New Issue
Block a user