[gnome-boxes] broker: Purge stale box configs from newly added sources



commit 3d71b44d090fa19e4ac7af3557c1b4924b9c9929
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Mar 29 04:52:23 2013 +0200

    broker: Purge stale box configs from newly added sources
    
    After adding a new source, purge all stale box configs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683489

 src/app.vala            |   13 ++++++++++++-
 src/libvirt-broker.vala |    2 ++
 src/ovirt-broker.vala   |    2 ++
 3 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 872d8e8..e843ee3 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -4,7 +4,18 @@ using Gdk;
 using Clutter;
 
 private abstract class Boxes.Broker : GLib.Object {
-    public abstract async void add_source (CollectionSource source);
+    // Overriding subclass should chain-up at the end of its implementation
+    public virtual async void add_source (CollectionSource source) {
+        var used_configs = new GLib.List<BoxConfig> ();
+        foreach (var item in App.app.collection.items.data) {
+            if (!(item is Machine))
+                continue;
+
+            used_configs.append ((item as Machine).config);
+        }
+
+        source.purge_stale_box_configs (used_configs);
+    }
 }
 
 private enum Boxes.AppPage {
diff --git a/src/libvirt-broker.vala b/src/libvirt-broker.vala
index 4e0185f..2a71768 100644
--- a/src/libvirt-broker.vala
+++ b/src/libvirt-broker.vala
@@ -100,6 +100,8 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
             debug ("New domain '%s'", domain.get_name ());
             try_add_new_domain (source, connection, domain);
         });
+
+        yield base.add_source (source);
     }
 }
 
diff --git a/src/ovirt-broker.vala b/src/ovirt-broker.vala
index b3f7f35..6e84b53 100644
--- a/src/ovirt-broker.vala
+++ b/src/ovirt-broker.vala
@@ -68,5 +68,7 @@ private class Boxes.OvirtBroker : Boxes.Broker {
         foreach (var vm in proxy.get_vms ()) {
             add_vm (source, proxy, vm);
         }
+
+        yield base.add_source (source);
     }
 }


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