[rygel] media-export: Delay rebuild of virtual containers



commit 3ff89b4c4d871fc4be23dcbbd5b54b6e98dfaed9
Author: Jens Georg <mail jensge org>
Date:   Sat Apr 16 14:11:11 2011 +0300

    media-export: Delay rebuild of virtual containers
    
    Delay the rebuild on file-system changes after the inital crawl. The
    solution introduced with 3305afc1cecc7ef26d5b7fdd588a3825cfe4b369 causes
    a massive stress on the SQLite database causing CPU load of 100% and
    causing a massive slow-down in the initial crawl.

 .../media-export/rygel-media-export-harvester.vala |    5 +++++
 .../rygel-media-export-root-container.vala         |   14 ++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala b/src/plugins/media-export/rygel-media-export-harvester.vala
index 3c8861a..ddf7504 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -30,6 +30,8 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
     private Regex file_filter;
     private Cancellable cancellable;
 
+    public signal void done ();
+
     /**
      * Create a new instance of the meta-data extraction manager.
      */
@@ -101,6 +103,9 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
         message (_("'%s' harvested"), file.get_uri ());
 
         this.tasks.unset (file);
+        if (this.tasks.is_empty) {
+            done ();
+        }
     }
 
     /**
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index 110a9e8..ebf6d4f 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -45,6 +45,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
     private Harvester      harvester;
     private Cancellable    cancellable;
     private MediaContainer filesystem_container;
+    private ulong          harvester_signal_id;
 
     private static MediaContainer instance = null;
     private static Error          creation_error = null;
@@ -365,6 +366,9 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
             ids = new ArrayList<string> ();
         }
 
+        this.harvester_signal_id = this.harvester.done.connect
+                                        (on_initial_harvesting_done);
+
         foreach (var file in this.get_shared_uris ()) {
             if (file.query_exists (null)) {
                 ids.remove (MediaCache.get_id (file));
@@ -382,14 +386,20 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
             }
         }
 
+        this.add_default_virtual_folders ();
+
+        this.updated ();
+    }
+
+    private void on_initial_harvesting_done () {
+        this.harvester.disconnect (this.harvester_signal_id);
+
         this.filesystem_container.container_updated.connect( () => {
             this.add_default_virtual_folders ();
             this.updated ();
         });
 
-        this.add_default_virtual_folders ();
 
-        this.updated ();
     }
 
     private void add_default_virtual_folders () {



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