Skip to content

Commit

Permalink
Merge pull request #435 from Murmele/flatpakUninstall
Browse files Browse the repository at this point in the history
Flatpak uninstall
  • Loading branch information
Murmele authored Jan 22, 2023
2 parents f364ff0 + 196b8c6 commit 627f73d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down
10 changes: 10 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 28 additions & 0 deletions src/update/Updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/update/Updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ class Updater : public QObject {

bool install(const DownloadRef &download, QString &error);

#if defined(FLATPAK) || defined(DEBUG_FLATPAK)
bool uninstallGittyup(bool system);
#endif

QNetworkAccessManager mMgr;
};

Expand Down

0 comments on commit 627f73d

Please sign in to comment.