[gnome-boxes] media-manager: Tidy up "connect to Tracker" code path



commit 721318b8e377c7742b1b2b672a554cf65b1387cf
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Dec 16 14:53:54 2021 +0100

    media-manager: Tidy up "connect to Tracker" code path
    
    Tracker provides our "Detected Sources" list of OS images in the
    new VM Assistant. This isn't really a "core" feature. It depends
    on connecting to the host tracker (which might not be there in
    some distros/environments) and, in case of the Flatpak, connecting
    to the bundled Tracker miner (which is limited to the Boxes sandbox
    permissions).
    
    All in all, nothing here is "critical".

 src/media-manager.vala | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/src/media-manager.vala b/src/media-manager.vala
index 5e585e2c..be211d54 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -8,9 +8,6 @@
     private static MediaManager media_manager;
 
     public OSDatabase os_db { get; private set; }
-#if !FLATPAK
-    public GUdev.Client client { get; private set; }
-#endif
 
     public delegate void InstallerRecognized (Osinfo.Media os_media, Osinfo.Os os);
 
@@ -91,6 +88,8 @@ else if (VMConfigurator.is_libvirt_cloning_config (config))
         var list = new GLib.List<InstallerMedia> ();
 
 #if !FLATPAK
+        GUdev.Client client = new GUdev.Client ({"block"});
+
         // First HW media
         var enumerator = new GUdev.Enumerator (client);
         // We don't want to deal with partitions to avoid duplicate medias
@@ -221,9 +220,6 @@ public InstallerMedia create_installer_media_from_media (InstallerMedia media, O
     }
 
     private MediaManager () {
-#if !FLATPAK
-        client = new GUdev.Client ({"block"});
-#endif
         os_db = new OSDatabase ();
         os_db.load.begin ();
     }
@@ -233,17 +229,19 @@ public async void connect_to_tracker () {
             connection = Sparql.Connection.bus_new ("org.freedesktop.Tracker3.Miner.Files",
                                                     null, null);
         } catch (GLib.Error error) {
-#if !FLATPAK
-            critical ("Error connecting to Tracker: %s", error.message);
-#else
+            if (!App.is_running_in_flatpak ()) {
+                message ("Error connecting to Tracker: %s", error.message);
+
+                return;
+            }
+
             message ("Error connecting to host Tracker Miners: %s", error.message);
             try {
                 connection = Sparql.Connection.bus_new (Config.APPLICATION_ID + "Tracker3.Miner.Files",
                                                         null, null);
             } catch (GLib.Error error) {
-                critical ("Error starting local Tracker Miners: %s", error.message);
+                warning ("Error starting local Tracker Miners: %s", error.message);
             }
-#endif
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]