From 55f845371499e29a7f0d4ddf1abc072c8cd54bd5 Mon Sep 17 00:00:00 2001 From: waker Date: Sat, 14 May 2011 20:37:55 +0200 Subject: fixed artwork custom filemask search order bug --- plugins/artwork/artwork.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'plugins/artwork') diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c index 73421ab4..9357f160 100644 --- a/plugins/artwork/artwork.c +++ b/plugins/artwork/artwork.c @@ -709,28 +709,12 @@ copy_file (const char *in, const char *out, int img_size) { return 0; } +static const char *filter_custom_mask = NULL; static int filter_custom (const struct dirent *f) { - char mask[200] = ""; - char *p = artwork_filemask; - while (p) { - *mask = 0; - char *e = strchr (p, ';'); - if (e) { - strncpy (mask, p, e-p); - mask[e-p] = 0; - e++; - } - else { - strcpy (mask, p); - } - if (*mask) { - if (!fnmatch (mask, f->d_name, FNM_CASEFOLD)) { - return 1; - } - } - p = e; + if (!fnmatch (filter_custom_mask, f->d_name, FNM_CASEFOLD)) { + return 1; } return 0; } @@ -969,9 +953,30 @@ fetcher_thread (void *none) *slash = 0; // assuming at least one slash exist } trace ("scanning directory: %s\n", path); - files_count = scandir (path, &files, filter_custom, alphasort); + char mask[200] = ""; + char *p = artwork_filemask; + while (p) { + *mask = 0; + char *e = strchr (p, ';'); + if (e) { + strncpy (mask, p, e-p); + mask[e-p] = 0; + e++; + } + else { + strcpy (mask, p); + } + if (*mask) { + filter_custom_mask = mask; + files_count = scandir (path, &files, filter_custom, NULL); + if (files_count != 0) { + break; + } + } + p = e; + } if (files_count == 0) { - files_count = scandir (path, &files, filter_jpg, alphasort); + files_count = scandir (path, &files, filter_jpg, NULL); } if (files_count > 0) { -- cgit v1.2.3