mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Continue to run new HQ Launcher if auto-updater fails
This commit is contained in:
parent
746a800f0f
commit
53b4ff724d
5 changed files with 21 additions and 16 deletions
|
@ -60,22 +60,17 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt
|
||||||
outFile.close();
|
outFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void swapLaunchers(const QString& oldLauncherPath, const QString& newLauncherPath) {
|
bool swapLaunchers(const QString& oldLauncherPath, const QString& newLauncherPath) {
|
||||||
if (!(QFileInfo::exists(oldLauncherPath) && QFileInfo::exists(newLauncherPath))) {
|
if (!(QFileInfo::exists(oldLauncherPath) && QFileInfo::exists(newLauncherPath))) {
|
||||||
qDebug() << "old launcher: " << oldLauncherPath << "new launcher: " << newLauncherPath << " file does not exist";
|
qDebug() << "old launcher: " << oldLauncherPath << "new launcher: " << newLauncherPath << " file does not exist";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
qDebug() << "replacing launchers -> old launcher: " << oldLauncherPath << " new launcher: " << newLauncherPath;
|
||||||
success = replaceDirectory(oldLauncherPath, newLauncherPath);
|
success = replaceDirectory(oldLauncherPath, newLauncherPath);
|
||||||
#endif
|
#endif
|
||||||
|
return success;
|
||||||
if (success) {
|
|
||||||
qDebug() << "succeessfully replaced";
|
|
||||||
} else {
|
|
||||||
qDebug() << "failed";
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ void launchClient(const QString& clientPath, const QString& homePath, const QStr
|
||||||
|
|
||||||
|
|
||||||
void launchAutoUpdater(const QString& autoUpdaterPath);
|
void launchAutoUpdater(const QString& autoUpdaterPath);
|
||||||
void swapLaunchers(const QString& oldLauncherPath = QString(), const QString& newLauncherPath = QString());
|
bool swapLaunchers(const QString& oldLauncherPath = QString(), const QString& newLauncherPath = QString());
|
||||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message);
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message);
|
||||||
void cleanLogFile();
|
void cleanLogFile();
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,17 @@ void launchAutoUpdater(const QString& autoUpdaterPath) {
|
||||||
|
|
||||||
|
|
||||||
bool replaceDirectory(const QString& orginalDirectory, const QString& newDirectory) {
|
bool replaceDirectory(const QString& orginalDirectory, const QString& newDirectory) {
|
||||||
|
NSError *error = nil;
|
||||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||||
NSURL* destinationUrl = [UpdaterHelper NSStringToNSURL:newDirectory.toNSString()];
|
NSURL* destinationUrl = [UpdaterHelper NSStringToNSURL:newDirectory.toNSString()];
|
||||||
return (bool) [fileManager replaceItemAtURL:[UpdaterHelper NSStringToNSURL:orginalDirectory.toNSString()] withItemAtURL:[UpdaterHelper NSStringToNSURL:newDirectory.toNSString()]
|
bool success = (bool) [fileManager replaceItemAtURL:[UpdaterHelper NSStringToNSURL:orginalDirectory.toNSString()] withItemAtURL:[UpdaterHelper NSStringToNSURL:newDirectory.toNSString()]
|
||||||
backupItemName:nil options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:&destinationUrl error:nil];
|
backupItemName:nil options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:&destinationUrl error:&error];
|
||||||
|
|
||||||
|
if (error != nil) {
|
||||||
|
qDebug() << "NSFileManager::replaceItemAtURL -> error: " << error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +131,6 @@ void waitForInterfaceToClose() {
|
||||||
bool isLauncherAlreadyRunning() {
|
bool isLauncherAlreadyRunning() {
|
||||||
NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"];
|
NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"];
|
||||||
if ([apps count] > 1) {
|
if ([apps count] > 1) {
|
||||||
NSLog(@"launcher is already running");
|
|
||||||
qDebug() << "launcher is already running";
|
qDebug() << "launcher is already running";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ void LoginRequest::receivedResponse() {
|
||||||
_token.refreshToken = root["refresh_token"].toString();
|
_token.refreshToken = root["refresh_token"].toString();
|
||||||
_token.tokenType = root["token_type"].toString();
|
_token.tokenType = root["token_type"].toString();
|
||||||
|
|
||||||
qDebug() << "Got response for login: " << data;
|
qDebug() << "Got response for login";
|
||||||
_rawLoginToken = data;
|
_rawLoginToken = data;
|
||||||
|
|
||||||
emit finished();
|
emit finished();
|
||||||
|
|
|
@ -37,6 +37,8 @@ int main(int argc, char *argv[]) {
|
||||||
Q_INIT_RESOURCE(resources);
|
Q_INIT_RESOURCE(resources);
|
||||||
cleanLogFile();
|
cleanLogFile();
|
||||||
qInstallMessageHandler(messageHandler);
|
qInstallMessageHandler(messageHandler);
|
||||||
|
CommandlineOptions* options = CommandlineOptions::getInstance();
|
||||||
|
options->parse(argc, argv);
|
||||||
bool didUpdate = false;
|
bool didUpdate = false;
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
if (isLauncherAlreadyRunning()) {
|
if (isLauncherAlreadyRunning()) {
|
||||||
|
@ -45,13 +47,15 @@ int main(int argc, char *argv[]) {
|
||||||
closeInterfaceIfRunning();
|
closeInterfaceIfRunning();
|
||||||
if (argc == 3) {
|
if (argc == 3) {
|
||||||
if (hasSuffix(argv[1], "app") && hasSuffix(argv[2], "app")) {
|
if (hasSuffix(argv[1], "app") && hasSuffix(argv[2], "app")) {
|
||||||
swapLaunchers(argv[1], argv[2]);
|
bool success = swapLaunchers(argv[1], argv[2]);
|
||||||
|
qDebug() << "Launcher install success: " << success;
|
||||||
|
if (!success) {
|
||||||
|
options->append("--noUpdate");
|
||||||
|
}
|
||||||
didUpdate = true;
|
didUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
CommandlineOptions* options = CommandlineOptions::getInstance();
|
|
||||||
options->parse(argc, argv);
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
LauncherInstaller launcherInstaller(argv[0]);
|
LauncherInstaller launcherInstaller(argv[0]);
|
||||||
if (options->contains("--uninstall") || options->contains("--resumeUninstall")) {
|
if (options->contains("--uninstall") || options->contains("--resumeUninstall")) {
|
||||||
|
|
Loading…
Reference in a new issue