diff --git a/CMakeLists.txt b/CMakeLists.txt index a1ca20d2..8f58abfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(Gittyup) set(GITTYUP_NAME "Gittyup") set(GITTYUP_VERSION_MAJOR 1) set(GITTYUP_VERSION_MINOR 2) -set(GITTYUP_VERSION_PATCH 1) +set(GITTYUP_VERSION_PATCH 2) set(GITTYUP_VERSION "${GITTYUP_VERSION_MAJOR}.${GITTYUP_VERSION_MINOR}.${GITTYUP_VERSION_PATCH}" ) diff --git a/docs/changelog.md b/docs/changelog.md index aee7fd05..5bace189 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,13 @@ +### v1.2.2 - 2023-01-22 + +Bug fix release + +#### Changed + +* Fix flatpak install process + +---- + ### v1.2.1 - 2023-01-22 Bug fix release diff --git a/src/update/Updater.cpp b/src/update/Updater.cpp index ef454de5..d6d23a11 100644 --- a/src/update/Updater.cpp +++ b/src/update/Updater.cpp @@ -271,9 +271,36 @@ Updater *Updater::instance() { } #if defined(FLATPAK) || defined(DEBUG_FLATPAK) +bool Updater::uninstallGittyup(bool system) { + QString bash = git::Command::bashPath(); + QString loc = system ? "--system" : "--user"; + + QStringList args; + args.append("-c"); + args.append(QString("flatpak-spawn --host flatpak remove -y %1 " + "com.github.Murmele.Gittyup") + .arg(loc)); + auto *p = new QProcess(this); + + p->start(bash, args); + if (!p->waitForFinished()) { + const QString es = p->errorString(); + qDebug() << "Uninstalling Gittyup failed: " + es; + return false; + } else { + qDebug() << "Uninstall: " + p->readAll(); + } + p->deleteLater(); + return true; +} + bool Updater::install(const DownloadRef &download, QString &error) { QString path = download->file()->fileName(); + // Ignore return value + uninstallGittyup(true); + uninstallGittyup(false); + QDir dir(QCoreApplication::applicationDirPath()); QStringList args; args.append("-c"); @@ -294,6 +321,7 @@ bool Updater::install(const DownloadRef &download, QString &error) { } else { qDebug() << "Successfully installed bundle: " + p->readAll(); } + p->deleteLater(); auto relauncher_cmd = dir.filePath("relauncher"); qDebug() << "Relauncher command: " << relauncher_cmd; diff --git a/src/update/Updater.h b/src/update/Updater.h index 29c33cb3..bd767c07 100644 --- a/src/update/Updater.h +++ b/src/update/Updater.h @@ -62,6 +62,10 @@ private: bool install(const DownloadRef &download, QString &error); +#if defined(FLATPAK) || defined(DEBUG_FLATPAK) + bool uninstallGittyup(bool system); +#endif + QNetworkAccessManager mMgr; };