[rygel] media-export: Add option to disable file monitors



commit 2acc302ce6b0729c5e062d880da686dae5cb51c7
Author: Jens Georg <mail jensge org>
Date:   Sun Apr 17 12:03:15 2011 +0300

    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/
           <para>Set to <userinput>false</userinput> 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 <option>include-filter</option>, otherwise you will end up with a lot of files exposed which the client cannot display anyway.</para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term>
+          <option>monitor-changes</option>
+        </term>
+        <listitem>
+          <para>Set to <userinput>false</userinput> if you don&apos;t want to have new files picked up automatically by &dhpackage;.</para>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
   <refsect1>
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<File, FileMonitor> 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<File, FileMonitor> (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,



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