Bug 447937 - Flatpak runtime version numbers are nonsensical on update page
Summary: Flatpak runtime version numbers are nonsensical on update page
Status: RESOLVED FIXED
Alias: None
Product: Discover
Classification: Applications
Component: Flatpak Backend (show other bugs)
Version: master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Dan Leinir Turthra Jensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-04 15:18 UTC by Nate Graham
Modified: 2022-07-21 09:10 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Nonsense update numbers (413.75 KB, image/png)
2022-01-04 15:18 UTC, Nate Graham
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Graham 2022-01-04 15:18:17 UTC
Created attachment 145109 [details]
Nonsense update numbers

This is related to Bug 447033, but not quite the same thing.

Basically the version number display for Flatpak runtimes are nonsense, often displaying text like "(5.15-21.08) -> 5.15-21.08" or "(41) -> 41". See attached screenshot. The old and new versions can't always be the same, and why is the old number within parentheses while the new one isn't?
Comment 1 Timothée Ravier 2022-01-07 10:24:07 UTC
*** Bug 447361 has been marked as a duplicate of this bug. ***
Comment 2 Prajna Sariputra 2022-04-03 12:41:47 UTC
Seems like this commit should fix it: https://invent.kde.org/plasma/discover/-/commit/c2f751eb8bf5edbf5b1adea81e6403d94d838401

I ended up writing a patch for myself that does basically the same thing for 5.24.4 (copied below for reference), which fixed the issue for me, as in Discover now says "Update to version ..." for all cases where the version number doesn't change instead of " (...) -> ...", didn't occur to me to check master before going to the trouble lol. The issue was that if the flatpak has no version field and only a branch name (which is the case for the GNOME and KDE runtimes, but not the Freedesktop runtime, this can be seen via the output of `flatpak info`) the old version string ends up looking like " (branch)" while the new version string is just "branch", hence Discover thinks there is a version change and attempts to show that.


diff --color --unified --recursive --text discover-5.24.4/libdiscover/backends/FlatpakBackend/FlatpakResource.cpp discover-5.24.4.new/libdiscover/backends/FlatpakBackend/FlatpakResource.cpp
--- discover-5.24.4/libdiscover/backends/FlatpakBackend/FlatpakResource.cpp	2022-03-29 22:14:29.000000000 +1100
+++ discover-5.24.4.new/libdiscover/backends/FlatpakBackend/FlatpakResource.cpp	2022-04-03 21:59:03.213976326 +1000
@@ -231,7 +231,10 @@
     }
 
     if (auto ref = qobject_cast<FlatpakBackend *>(backend())->getInstalledRefForApp(this)) {
-        return i18nc("version (branch)", "%1 (%2)", flatpak_installed_ref_get_appdata_version(ref), version);
+        QString appdataVersion = flatpak_installed_ref_get_appdata_version(ref);
+        if (!appdataVersion.isEmpty()) {
+            return i18nc("version (branch)", "%1 (%2)", appdataVersion, version);
+        }
     }
     return version;
 }
Comment 3 Nate Graham 2022-04-03 22:27:47 UTC
Please feel free to submit a merge request with that patch targeted at the Plasma/5.24 branch! 5.24 is an LTS release so it would be a good thing to have fixed there too.
Comment 4 Prajna Sariputra 2022-04-03 23:27:17 UTC
I cherrypicked the commit from master into this MR for the Plasma/5.24 branch: https://invent.kde.org/plasma/discover/-/merge_requests/287
Comment 5 Prajna Sariputra 2022-04-04 11:57:25 UTC
The MR for the Plasma/5.24 branch has been merged, so I guess it'll be in 5.24.5 whenever that comes out.