[rygel] media-export: Re-add skipping of text files



commit 2a655978882054a1a51da284c5d5165c162b1684
Author: Jens Georg <mail jensge org>
Date:   Sun Jul 5 16:45:45 2015 +0200

    media-export: Re-add skipping of text files
    
    Signed-off-by: Jens Georg <mail jensge org>

 .../media-export/rygel-media-export-extract.vala   |   27 +++++++++++++------
 .../rygel-media-export-metadata-extractor.vala     |    2 +-
 2 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-extract.vala 
b/src/plugins/media-export/rygel-media-export-extract.vala
index aba853e..be830e2 100644
--- a/src/plugins/media-export/rygel-media-export-extract.vala
+++ b/src/plugins/media-export/rygel-media-export-extract.vala
@@ -85,25 +85,34 @@ async void run () {
 
             if (line.has_prefix ("EXTRACT ")) {
                 debug ("Got command to extract file: %s", line);
-                var uri = line.replace ("EXTRACT ", "").strip ();
+                var data = line.replace ("EXTRACT ", "").strip ();
+                var parts = data.split ("|");
+                if (parts.length != 2) {
+                    warning (_("Invalid command received, ignoring"));
+
+                    continue;
+                }
                 DiscovererInfo? info = null;
                 try {
                     // Copy current URI to statically allocated memory area to
                     // dump to fd in the signal handler
-                    last_uri.length = uri.length;
+                    last_uri.length = parts[0].length;
                     GLib.Memory.set (last_uri.data, 0, 4096);
-                    GLib.Memory.copy (last_uri.data, (void *) uri, uri.length);
-                    if (metadata) {
-                        info = discoverer.discover_uri (uri);
-
-                        debug ("Finished discover on uri %s", uri);
+                    GLib.Memory.copy (last_uri.data,
+                                      (void *) parts[0],
+                                      parts[0].length);
+                    var is_text = parts[1].has_prefix ("text/");
+                    if (metadata && !is_text) {
+                        info = discoverer.discover_uri (parts[0]);
+
+                        debug ("Finished discover on uri %s", parts[0]);
                     }
-                    yield process_meta_data (uri, info);
+                    yield process_meta_data (parts[0], info);
                 } catch (Error error) {
                     warning (_("Failed to discover uri %s: %s"),
-                             uri,
+                             parts[0],
                              error.message);
-                    send_error (File.new_for_uri (uri), error);
+                    send_error (File.new_for_uri (parts[0]), error);
 
                     // Recreate the discoverer on error
                     discoverer = new Discoverer (10 * Gst.SECOND);
diff --git a/src/plugins/media-export/rygel-media-export-metadata-extractor.vala 
b/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
index 3ca77c4..2a579f0 100644
--- a/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
+++ b/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
@@ -283,7 +283,7 @@ public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
             return;
         }
 
-        var s = "EXTRACT %s\n".printf (file.get_uri ());
+        var s = "EXTRACT %s|%s\n".printf (file.get_uri (), content_type);
         try {
             this.input_stream.write_all (s.data, null, this.child_io_cancellable);
             this.input_stream.flush ();


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