[rygel] media-export: Make grace period configurable
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Make grace period configurable
- Date: Sun, 15 Jun 2014 07:59:08 +0000 (UTC)
commit c70a2a3a6a7dbf7c3aa8093a27bba754032e7fbd
Author: Jens Georg <mail jensge org>
Date: Sun Jun 15 09:34:06 2014 +0200
media-export: Make grace period configurable
While it helps not to run discover on half-downloaded files, it slows down the
server sync use-case and breaks several DLNA requirements.
It can turned off now using monitor-grace-timeout=0
Signed-off-by: Jens Georg <mail jensge org>
https://bugzilla.gnome.org/show_bug.cgi?id=694455
data/rygel.conf | 1 +
doc/man/rygel.conf.xml | 8 +++++
.../media-export/rygel-media-export-harvester.vala | 29 +++++++++++++++++---
3 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/data/rygel.conf b/data/rygel.conf
index 84dbeb8..2293326 100644
--- a/data/rygel.conf
+++ b/data/rygel.conf
@@ -111,6 +111,7 @@ title= REALNAME@'s media
uris= MUSIC@;@VIDEOS@;@PICTURES@
extract-metadata=true
monitor-changes=true
+monitor-grace-timeout=5
virtual-folders=true
[Playbin]
diff --git a/doc/man/rygel.conf.xml b/doc/man/rygel.conf.xml
index 150159c..5cab37f 100644
--- a/doc/man/rygel.conf.xml
+++ b/doc/man/rygel.conf.xml
@@ -372,6 +372,14 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
</varlistentry>
<varlistentry>
<term>
+ <option>monitor-grace-timeout</option>
+ </term>
+ <listitem>
+ <para>Time in seconds to wait after a new file has been detected before trying to extract
meta-data from it. Useful if you're downloading to a directory watched by &dhpackage;. Default is 5
seconds.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
<option>virtual-folders</option>
</term>
<listitem>
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala
b/src/plugins/media-export/rygel-media-export-harvester.vala
index d85489c..0b8b1db 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -144,8 +144,15 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
File? other,
FileMonitorEvent event) {
try {
+ var info = file.query_info (FileAttribute.STANDARD_TYPE,
+ FileQueryInfoFlags.NONE,
+ this.cancellable);
switch (event) {
case FileMonitorEvent.CREATED:
+ if (info.get_file_type () == FileType.DIRECTORY) {
+ this.on_changes_done (file);
+ }
+ break;
case FileMonitorEvent.CHANGES_DONE_HINT:
this.on_changes_done (file);
break;
@@ -223,9 +230,19 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
return;
}
+ var period = FILE_CHANGE_DEFAULT_GRACE_PERIOD;
+ try {
+ var config = MetaConfig.get_default ();
+ period = config.get_int ("MediaExport",
+ "monitor-grace-timeout",
+ 0,
+ 500);
+ } catch (Error error) { }
+
+
if (this.extraction_grace_timers.has_key (file)) {
Source.remove (this.extraction_grace_timers[file]);
- } else {
+ } else if (period > 0) {
debug ("Starting grace timer for harvesting %s…",
file.get_uri ());
}
@@ -236,8 +253,12 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
return false;
};
- var timeout = Timeout.add_seconds (FILE_CHANGE_DEFAULT_GRACE_PERIOD,
- (owned) callback);
- this.extraction_grace_timers[file] = timeout;
+ if (period > 0) {
+ var timeout = Timeout.add_seconds (FILE_CHANGE_DEFAULT_GRACE_PERIOD,
+ (owned) callback);
+ this.extraction_grace_timers[file] = timeout;
+ } else {
+ Idle.add ((owned) callback);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]