[rygel] media-export: Respect .nomedia for skipping folder



commit d3ef8793a38ecde5d5573af6b0ee655ff3eb7de3
Author: Jens Georg <mail jensge org>
Date:   Sun Dec 27 16:40:37 2020 +0100

    media-export: Respect .nomedia for skipping folder
    
    Fixes #187

 src/plugins/media-export/rygel-media-export-harvester.vala       | 7 +++++--
 src/plugins/media-export/rygel-media-export-harvesting-task.vala | 4 ++++
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala 
b/src/plugins/media-export/rygel-media-export-harvester.vala
index 3c4f3fd3..f86dc803 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -67,6 +67,10 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
      * @return true if file should be extracted, false otherwise
      */
     public static bool is_eligible (File file, FileInfo info) {
+        if (info.get_file_type () == FileType.DIRECTORY) {
+            return !file.get_child (".nomedia").query_exists ();
+        }
+
         var is_supported_content_type =
             info.get_content_type ().has_prefix ("image/") ||
             info.get_content_type ().has_prefix ("video/") ||
@@ -191,8 +195,7 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
                                         FileAttribute.STANDARD_CONTENT_TYPE,
                                         FileQueryInfoFlags.NONE,
                                         this.cancellable);
-            if (info.get_file_type () == FileType.DIRECTORY ||
-                Harvester.is_eligible (file, info)) {
+            if (Harvester.is_eligible (file, info)) {
                 var id = MediaCache.get_id (file.get_parent ());
                 try {
                     var parent_container = cache.get_object (id)
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala 
b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index 1cc4b8a5..05285e18 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -210,6 +210,10 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
         }
 
         if (info.get_file_type () == FileType.DIRECTORY) {
+            if (!Harvester.is_eligible (file, info)) {
+                return false;
+            }
+
             // queue directory for processing later
             this.monitor.add.begin (file);
 


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