mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Retry self copy if the old launcher is still shutting down.
This commit is contained in:
parent
f02b76fed0
commit
ecd078f6d3
4 changed files with 37 additions and 12 deletions
|
@ -72,9 +72,7 @@ BOOL CLauncherApp::InitInstance() {
|
||||||
} else {
|
} else {
|
||||||
_manager.init(!noUpdate, continueAction);
|
_manager.init(!noUpdate, continueAction);
|
||||||
}
|
}
|
||||||
if (!_manager.hasFailed() && !_manager.installLauncher()) {
|
_manager.tryToInstallLauncher();
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
installFont(IDR_FONT_REGULAR);
|
installFont(IDR_FONT_REGULAR);
|
||||||
installFont(IDR_FONT_BOLD);
|
installFont(IDR_FONT_BOLD);
|
||||||
CWinApp::InitInstance();
|
CWinApp::InitInstance();
|
||||||
|
|
|
@ -656,7 +656,6 @@ BOOL CLauncherDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
||||||
|
|
||||||
void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) {
|
void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) {
|
||||||
|
|
||||||
|
|
||||||
if (theApp._manager.hasFailed() && _drawStep != DrawStep::DrawError) {
|
if (theApp._manager.hasFailed() && _drawStep != DrawStep::DrawError) {
|
||||||
theApp._manager.saveErrorLog();
|
theApp._manager.saveErrorLog();
|
||||||
prepareProcess(DrawStep::DrawError);
|
prepareProcess(DrawStep::DrawError);
|
||||||
|
@ -757,6 +756,9 @@ void CLauncherDlg::OnTimer(UINT_PTR nIDEvent) {
|
||||||
_applicationWND = theApp._manager.launchApplication();
|
_applicationWND = theApp._manager.launchApplication();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (theApp._manager.needsToSelfInstall()) {
|
||||||
|
theApp._manager.tryToInstallLauncher(TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLauncherDlg::setVerticalElement(CWnd* element, int verticalOffset, int heightOffset, bool fromMainWindowBottom) {
|
void CLauncherDlg::setVerticalElement(CWnd* element, int verticalOffset, int heightOffset, bool fromMainWindowBottom) {
|
||||||
|
|
|
@ -108,7 +108,7 @@ void LauncherManager::saveErrorLog() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL LauncherManager::installLauncher() {
|
void LauncherManager::tryToInstallLauncher(BOOL retry) {
|
||||||
CString appPath;
|
CString appPath;
|
||||||
BOOL result = getAndCreatePaths(PathType::Running_Path, appPath);
|
BOOL result = getAndCreatePaths(PathType::Running_Path, appPath);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
@ -126,26 +126,49 @@ BOOL LauncherManager::installLauncher() {
|
||||||
if (!_shouldUninstall) {
|
if (!_shouldUninstall) {
|
||||||
// The installer is not running on the desired location and has to be installed
|
// The installer is not running on the desired location and has to be installed
|
||||||
// Kill of running before self-copy
|
// Kill of running before self-copy
|
||||||
addToLog(_T("Installing Launcher."));
|
addToLog(_T("Trying to install launcher."));
|
||||||
int launcherPID = -1;
|
int launcherPID = -1;
|
||||||
if (LauncherUtils::isProcessRunning(LAUNCHER_EXE_FILENAME, launcherPID)) {
|
if (LauncherUtils::isProcessRunning(LAUNCHER_EXE_FILENAME, launcherPID)) {
|
||||||
if (!LauncherUtils::shutdownProcess(launcherPID, 0)) {
|
if (!LauncherUtils::shutdownProcess(launcherPID, 0)) {
|
||||||
addToLog(_T("Error shutting down the Launcher"));
|
addToLog(_T("Error shutting down the Launcher"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CopyFile(appPath, instalationPath, FALSE);
|
const int LAUNCHER_INSTALL_RETRYS = 10;
|
||||||
|
const int WAIT_BETWEEN_RETRYS_MS = 10;
|
||||||
|
int installTrys = retry ? LAUNCHER_INSTALL_RETRYS : 0;
|
||||||
|
for (int i = 0; i <= installTrys; i++) {
|
||||||
|
_retryLauncherInstall = !CopyFile(appPath, instalationPath, FALSE);
|
||||||
|
if (!_retryLauncherInstall) {
|
||||||
|
addToLog(_T("Launcher installed successfully."));
|
||||||
|
break;
|
||||||
|
} else if (i < installTrys) {
|
||||||
|
CString msg;
|
||||||
|
msg.Format(_T("Installing launcher try: %d"), i);
|
||||||
|
addToLog(msg);
|
||||||
|
Sleep(WAIT_BETWEEN_RETRYS_MS);
|
||||||
|
} else if (installTrys > 0) {
|
||||||
|
addToLog(_T("Error installing launcher."));
|
||||||
|
_retryLauncherInstall = false;
|
||||||
|
_hasFailed = true;
|
||||||
|
} else {
|
||||||
|
addToLog(_T("Old launcher is still running. Install could not be completed."));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (_shouldUninstall) {
|
} else if (_shouldUninstall) {
|
||||||
addToLog(_T("Launching Uninstall mode."));
|
addToLog(_T("Launching Uninstall mode."));
|
||||||
CString tempPath;
|
CString tempPath;
|
||||||
if (getAndCreatePaths(PathType::Temp_Directory, tempPath)) {
|
if (getAndCreatePaths(PathType::Temp_Directory, tempPath)) {
|
||||||
tempPath += _T("\\HQ_uninstaller_tmp.exe");
|
tempPath += _T("\\HQ_uninstaller_tmp.exe");
|
||||||
CopyFile(instalationPath, tempPath, false);
|
if (!CopyFile(instalationPath, tempPath, false)) {
|
||||||
LauncherUtils::launchApplication(tempPath, _T(" --uninstall"));
|
addToLog(_T("Error copying uninstaller to tmp directory."));
|
||||||
exit(0);
|
_hasFailed = true;
|
||||||
|
} else {
|
||||||
|
LauncherUtils::launchApplication(tempPath, _T(" --uninstall"));
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL LauncherManager::restartLauncher() {
|
BOOL LauncherManager::restartLauncher() {
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
BOOL deleteShortcuts();
|
BOOL deleteShortcuts();
|
||||||
HWND launchApplication();
|
HWND launchApplication();
|
||||||
BOOL uninstallApplication();
|
BOOL uninstallApplication();
|
||||||
BOOL installLauncher();
|
void tryToInstallLauncher(BOOL retry = FALSE);
|
||||||
BOOL restartLauncher();
|
BOOL restartLauncher();
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
|
@ -108,6 +108,7 @@ public:
|
||||||
BOOL needsInstall() const { return _shouldInstall; }
|
BOOL needsInstall() const { return _shouldInstall; }
|
||||||
BOOL needsToWait() const { return _shouldWait; }
|
BOOL needsToWait() const { return _shouldWait; }
|
||||||
BOOL needsRestartNewLauncher() const { return _shouldRestartNewLauncher; }
|
BOOL needsRestartNewLauncher() const { return _shouldRestartNewLauncher; }
|
||||||
|
BOOL needsToSelfInstall() const { return _retryLauncherInstall; }
|
||||||
BOOL willContinueUpdating() const { return _keepUpdating; }
|
BOOL willContinueUpdating() const { return _keepUpdating; }
|
||||||
ContinueActionOnStart getContinueAction() { return _continueAction; }
|
ContinueActionOnStart getContinueAction() { return _continueAction; }
|
||||||
void setDisplayName(const CString& displayName) { _displayName = displayName; }
|
void setDisplayName(const CString& displayName) { _displayName = displayName; }
|
||||||
|
@ -164,6 +165,7 @@ private:
|
||||||
BOOL _shouldRestartNewLauncher { FALSE };
|
BOOL _shouldRestartNewLauncher { FALSE };
|
||||||
BOOL _keepLoggingIn { FALSE };
|
BOOL _keepLoggingIn { FALSE };
|
||||||
BOOL _keepUpdating { FALSE };
|
BOOL _keepUpdating { FALSE };
|
||||||
|
BOOL _retryLauncherInstall { FALSE };
|
||||||
ContinueActionOnStart _continueAction;
|
ContinueActionOnStart _continueAction;
|
||||||
float _progressOffset { 0.0f };
|
float _progressOffset { 0.0f };
|
||||||
float _progress { 0.0f };
|
float _progress { 0.0f };
|
||||||
|
|
Loading…
Reference in a new issue