Skip to content

Commit 627f73d

Browse files
authored
Merge pull request #435 from Murmele/flatpakUninstall
Flatpak uninstall
2 parents f364ff0 + 196b8c6 commit 627f73d

4 files changed

Lines changed: 43 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ project(Gittyup)
55
set(GITTYUP_NAME "Gittyup")
66
set(GITTYUP_VERSION_MAJOR 1)
77
set(GITTYUP_VERSION_MINOR 2)
8-
set(GITTYUP_VERSION_PATCH 1)
8+
set(GITTYUP_VERSION_PATCH 2)
99
set(GITTYUP_VERSION
1010
"${GITTYUP_VERSION_MAJOR}.${GITTYUP_VERSION_MINOR}.${GITTYUP_VERSION_PATCH}"
1111
)

docs/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
### v1.2.2 - 2023-01-22
2+
3+
Bug fix release
4+
5+
#### Changed
6+
7+
* Fix flatpak install process
8+
9+
----
10+
111
### v1.2.1 - 2023-01-22
212

313
Bug fix release

src/update/Updater.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,36 @@ Updater *Updater::instance() {
271271
}
272272

273273
#if defined(FLATPAK) || defined(DEBUG_FLATPAK)
274+
bool Updater::uninstallGittyup(bool system) {
275+
QString bash = git::Command::bashPath();
276+
QString loc = system ? "--system" : "--user";
277+
278+
QStringList args;
279+
args.append("-c");
280+
args.append(QString("flatpak-spawn --host flatpak remove -y %1 "
281+
"com.github.Murmele.Gittyup")
282+
.arg(loc));
283+
auto *p = new QProcess(this);
284+
285+
p->start(bash, args);
286+
if (!p->waitForFinished()) {
287+
const QString es = p->errorString();
288+
qDebug() << "Uninstalling Gittyup failed: " + es;
289+
return false;
290+
} else {
291+
qDebug() << "Uninstall: " + p->readAll();
292+
}
293+
p->deleteLater();
294+
return true;
295+
}
296+
274297
bool Updater::install(const DownloadRef &download, QString &error) {
275298
QString path = download->file()->fileName();
276299

300+
// Ignore return value
301+
uninstallGittyup(true);
302+
uninstallGittyup(false);
303+
277304
QDir dir(QCoreApplication::applicationDirPath());
278305
QStringList args;
279306
args.append("-c");
@@ -294,6 +321,7 @@ bool Updater::install(const DownloadRef &download, QString &error) {
294321
} else {
295322
qDebug() << "Successfully installed bundle: " + p->readAll();
296323
}
324+
p->deleteLater();
297325

298326
auto relauncher_cmd = dir.filePath("relauncher");
299327
qDebug() << "Relauncher command: " << relauncher_cmd;

src/update/Updater.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ class Updater : public QObject {
6262

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

65+
#if defined(FLATPAK) || defined(DEBUG_FLATPAK)
66+
bool uninstallGittyup(bool system);
67+
#endif
68+
6569
QNetworkAccessManager mMgr;
6670
};
6771

0 commit comments

Comments
 (0)