From 1cd5b6d068f70da8b28e6a9df4e4d4eac7fa2e25 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Tue, 10 Oct 2017 17:59:00 -0700 Subject: binding: mediascanner: don't add directories from local scan Bug-AGL: SPEC-934 Change-Id: Ia881763c7c062f4a6aff74d43173fd19afdf3f4e Signed-off-by: Matt Ranostay --- binding/media-manager.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/binding/media-manager.c b/binding/media-manager.c index 445c7f9..2907972 100644 --- a/binding/media-manager.c +++ b/binding/media-manager.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -99,7 +100,17 @@ GList* media_local_scan(GList *list) while ((tmp = (gchar *) g_dir_read_name(dir)) != NULL) { struct Media_Item *item = g_malloc0(sizeof(*item)); - item->path = g_strdup_printf("file://%s/%s", path, tmp); + gchar *p = g_strconcat(path, "/", tmp, NULL); + GStatBuf buf; + + if (g_stat(p, &buf) != 0 || !S_ISREG(buf.st_mode)) { + g_free(p); + continue; + } + + item->path = g_strconcat("file://", p, NULL); + g_free(p); + list = g_list_append(list, item); } -- cgit 1.2.3-korg