diff --git a/launchers/qt/src/Helper.cpp b/launchers/qt/src/Helper.cpp index 42f76fe0fa..2fe3ecc46a 100644 --- a/launchers/qt/src/Helper.cpp +++ b/launchers/qt/src/Helper.cpp @@ -60,22 +60,17 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt 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))) { qDebug() << "old launcher: " << oldLauncherPath << "new launcher: " << newLauncherPath << " file does not exist"; } bool success = false; #ifdef Q_OS_MAC + qDebug() << "replacing launchers -> old launcher: " << oldLauncherPath << " new launcher: " << newLauncherPath; success = replaceDirectory(oldLauncherPath, newLauncherPath); #endif - - if (success) { - qDebug() << "succeessfully replaced"; - } else { - qDebug() << "failed"; - exit(0); - } + return success; } diff --git a/launchers/qt/src/Helper.h b/launchers/qt/src/Helper.h index 2d1f06052f..619b754c5a 100644 --- a/launchers/qt/src/Helper.h +++ b/launchers/qt/src/Helper.h @@ -12,7 +12,7 @@ void launchClient(const QString& clientPath, const QString& homePath, const QStr 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 cleanLogFile(); diff --git a/launchers/qt/src/Helper_darwin.mm b/launchers/qt/src/Helper_darwin.mm index 2015c830cf..8b7ad16a87 100644 --- a/launchers/qt/src/Helper_darwin.mm +++ b/launchers/qt/src/Helper_darwin.mm @@ -97,10 +97,17 @@ void launchAutoUpdater(const QString& autoUpdaterPath) { bool replaceDirectory(const QString& orginalDirectory, const QString& newDirectory) { + NSError *error = nil; NSFileManager* fileManager = [NSFileManager defaultManager]; NSURL* destinationUrl = [UpdaterHelper NSStringToNSURL:newDirectory.toNSString()]; - return (bool) [fileManager replaceItemAtURL:[UpdaterHelper NSStringToNSURL:orginalDirectory.toNSString()] withItemAtURL:[UpdaterHelper NSStringToNSURL:newDirectory.toNSString()] - backupItemName:nil options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:&destinationUrl error:nil]; + bool success = (bool) [fileManager replaceItemAtURL:[UpdaterHelper NSStringToNSURL:orginalDirectory.toNSString()] withItemAtURL:[UpdaterHelper NSStringToNSURL:newDirectory.toNSString()] + 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() { NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"]; if ([apps count] > 1) { - NSLog(@"launcher is already running"); qDebug() << "launcher is already running"; return true; } diff --git a/launchers/qt/src/LoginRequest.cpp b/launchers/qt/src/LoginRequest.cpp index ecbbd8d743..5aed5d2700 100644 --- a/launchers/qt/src/LoginRequest.cpp +++ b/launchers/qt/src/LoginRequest.cpp @@ -73,7 +73,7 @@ void LoginRequest::receivedResponse() { _token.refreshToken = root["refresh_token"].toString(); _token.tokenType = root["token_type"].toString(); - qDebug() << "Got response for login: " << data; + qDebug() << "Got response for login"; _rawLoginToken = data; emit finished(); diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp index 4e0e1b7437..c3971d03d9 100644 --- a/launchers/qt/src/main.cpp +++ b/launchers/qt/src/main.cpp @@ -37,6 +37,8 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(resources); cleanLogFile(); qInstallMessageHandler(messageHandler); + CommandlineOptions* options = CommandlineOptions::getInstance(); + options->parse(argc, argv); bool didUpdate = false; #ifdef Q_OS_MAC if (isLauncherAlreadyRunning()) { @@ -45,13 +47,15 @@ int main(int argc, char *argv[]) { closeInterfaceIfRunning(); if (argc == 3) { 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; } } #endif - CommandlineOptions* options = CommandlineOptions::getInstance(); - options->parse(argc, argv); #ifdef Q_OS_WIN LauncherInstaller launcherInstaller(argv[0]); if (options->contains("--uninstall") || options->contains("--resumeUninstall")) {