diff options
author | Jens Georg <mail@jensge.org> | 2011-04-16 14:11:11 +0300 |
---|---|---|
committer | Zeeshan Ali (Khattak) <zeeshanak@gnome.org> | 2011-04-16 17:49:14 +0300 |
commit | 3ff89b4c4d871fc4be23dcbbd5b54b6e98dfaed9 (patch) | |
tree | d616000717ce2b083511a9366b27d3168117e2c7 | |
parent | 2ca4b473aa0d5d3d558c60964f352954514e9841 (diff) | |
download | rygel-3ff89b4c4d871fc4be23dcbbd5b54b6e98dfaed9.tar.gz |
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.
-rw-r--r-- | src/plugins/media-export/rygel-media-export-harvester.vala | 5 | ||||
-rw-r--r-- | src/plugins/media-export/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 3c8861ab..ddf7504b 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 110a9e81..ebf6d4f4 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 () { |