summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-05-14 20:37:55 +0200
committerGravatar waker <wakeroid@gmail.com>2011-05-14 20:37:55 +0200
commit55f845371499e29a7f0d4ddf1abc072c8cd54bd5 (patch)
treeebad7dd14d2c727a5761d9412ca372375cb33ff0 /plugins
parent83cf2897f3069dee94549da7ace743b7303df2e7 (diff)
fixed artwork custom filemask search order bug
Diffstat (limited to 'plugins')
-rw-r--r--plugins/artwork/artwork.c47
1 files changed, 26 insertions, 21 deletions
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) {