[gnome-boxes/recommended-downloads-always-look-for-latest-version-in-osinfo-db: 2/5] recommended-downloads: Fallback to OSinfo.Os.id prefix when Os is not found
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/recommended-downloads-always-look-for-latest-version-in-osinfo-db: 2/5] recommended-downloads: Fallback to OSinfo.Os.id prefix when Os is not found
- Date: Wed, 2 Mar 2022 10:59:03 +0000 (UTC)
commit d7ec3096a336816e5b00c5a033f8c24364f0856a
Author: Felipe Borges <felipeborges gnome org>
Date: Wed Mar 2 11:33:48 2022 +0100
recommended-downloads: Fallback to OSinfo.Os.id prefix when Os is not found
If the exact Osinfo.Os.id isn't found in the Osinfo database, we
search for the latest version that matches the prefix of the OS id.
This allows the recommended-downloads list to contain incomplete
Osinfo.Os IDs, solving our issue with hardcoded version numbers.
src/util-app.vala | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/util-app.vala b/src/util-app.vala
index 690354b5..5cb92dda 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -205,15 +205,24 @@ else if (media_url.contains ("dvd"))
var os_db = MediaManager.get_default ().os_db;
for (Xml.Node* iter = root->children; iter != null; iter = iter->next) {
var os_id = iter->get_content ();
- try {
- var os = yield os_db.get_os_by_id (os_id);
- var media = os.get_media_list ().get_nth (0) as Osinfo.Media;
- if (media.url != null || os_id.has_prefix ("http://redhat.com"))
- list.append (media);
+ Osinfo.Os? os;
+ try {
+ os = yield os_db.get_os_by_id (os_id);
} catch (OSDatabaseError error) {
- debug ("Failed to find OS with id: '%s': %s", os_id, error.message);
+ // If the OS wasn't found, it means an os_id prefix was given
+ os = yield os_db.get_latest_release_for_os_prefix (os_id);
+ }
+
+ if (os == null) {
+ warning ("Failed to load %s", os_id);
+
+ continue;
}
+
+ var media = os.get_media_list ().get_nth (0) as Osinfo.Media;
+ if (media.url != null || os_id.has_prefix ("http://redhat.com"))
+ list.append (media);
}
return list;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]