From 2acc302ce6b0729c5e062d880da686dae5cb51c7 Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Sun, 17 Apr 2011 12:03:15 +0300 Subject: [PATCH] media-export: Add option to disable file monitors --- data/rygel.conf | 1 + doc/man/rygel.conf.xml | 8 ++++++++ .../rygel-media-export-recursive-file-monitor.vala | 22 ++++++++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/data/rygel.conf b/data/rygel.conf index 9af9908..7d30aee 100644 --- a/data/rygel.conf +++ b/data/rygel.conf @@ -86,6 +86,7 @@ title=@REALNAME@'s media uris=@MUSIC@;@VIDEOS@;@PICTURES@ include-filter=.mp3;.oga;.ogv;.ogg;.mkv;.avi;.mp4;.m4v;.m4a;.mpeg;.mpg;.ts;.flac;.jpeg;.jpg;.png;.wav;.wma;.wmv;.asf;.mpc;.mpp;.wv;.aac;.mka;.mp2;.webm extract-metadata=true +monitor-changes=true [Playbin] enabled=true diff --git a/doc/man/rygel.conf.xml b/doc/man/rygel.conf.xml index c5b255c..ca07db0 100644 --- a/doc/man/rygel.conf.xml +++ b/doc/man/rygel.conf.xml @@ -325,6 +325,14 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ Set to false if you do not care about duration or any other meta-data like artist. This speeds up the initial crawl of the media a lot. Use it to quickly share some files via UPnP. Make sure to define an , otherwise you will end up with a lot of files exposed which the client cannot display anyway. + + + + + + Set to false if you don't want to have new files picked up automatically by &dhpackage;. + + diff --git a/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala b/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala index 9925025..efd2cc4 100644 --- a/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala +++ b/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala @@ -20,13 +20,26 @@ using Gee; -using Rygel; public class Rygel.MediaExport.RecursiveFileMonitor : Object { - private Cancellable cancellable; + private Cancellable cancellable; HashMap monitors; + bool monitor_changes; public RecursiveFileMonitor (Cancellable? cancellable) { + this.monitor_changes = true; + try { + var config = MetaConfig.get_default (); + this.monitor_changes = config.get_bool ("MediaExport", + "monitor-changes"); + } catch (Error error) { + this.monitor_changes = true; + } + + if (!this.monitor_changes) { + message (_("Will not monitor file changes")); + } + this.cancellable = cancellable; this.monitors = new HashMap (GLib.file_hash, GLib.file_equal); @@ -63,6 +76,11 @@ public class Rygel.MediaExport.RecursiveFileMonitor : Object { } public async void add (File file) { + if (!this.monitor_changes || + this.monitors.has_key (file)) { + return; + } + try { var info = yield file.query_info_async (FILE_ATTRIBUTE_STANDARD_TYPE, -- 2.7.4