[rygel] media-export: harvest newly added files
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] media-export: harvest newly added files
- Date: Wed, 9 Sep 2009 20:38:42 +0000 (UTC)
commit 779050a5b6caf7b46a7493c5e6d52a60d3b78431
Author: Jens Georg <mail jensge org>
Date: Sat Jun 27 03:24:13 2009 +0200
media-export: harvest newly added files
.../rygel-media-export-root-container.vala | 28 +++++++++++++++-----
1 files changed, 21 insertions(+), 7 deletions(-)
---
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 f902f00..a5ca567 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -66,9 +66,10 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaDBContainer {
base (db, "0", "MediaExportRoot");
this.extractor = new MetadataExtractor ();
+
this.harvester = new ArrayList<MediaExportHarvester> ();
- this.monitor = new MediaExportRecursiveFileMonitor (null);
+ this.monitor = new MediaExportRecursiveFileMonitor (null);
this.monitor.changed.connect (this.on_file_changed);
var uris = get_uris ();
@@ -81,22 +82,35 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaDBContainer {
if (!this.media_db.exists (id)) {
debug ("Found new directory %s",
file.get_uri ());
- var harvest = new MediaExportHarvester (this,
- this.media_db,
- this.extractor,
- this.monitor);
- this.harvester.add (harvest);
- harvest.harvest (file);
+ this.harvest (file);
}
}
}
}
+ private void harvest (File file, MediaContainer parent = this) {
+ var harvest = new MediaExportHarvester (parent,
+ this.media_db,
+ this.extractor,
+ this.monitor);
+ this.harvester.add (harvest);
+ harvest.harvest (file);
+ }
+
private void on_file_changed (File file,
File? other,
FileMonitorEvent event) {
switch (event) {
case FileMonitorEvent.CREATED:
+ var parent = file.get_parent ();
+ var id = Checksum.compute_for_string (ChecksumType.MD5,
+ parent.get_uri ());
+ var parent_container = this.media_db.get_object (id);
+ if (parent_container != null) {
+ this.harvest (file, (MediaContainer)parent_container);
+ } else {
+ // This should not happen
+ }
break;
case FileMonitorEvent.CHANGES_DONE_HINT:
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]