From 766177bf10a7a603d3cf019043ca549d01014b25 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sat, 26 Oct 2013 20:59:05 +0200 Subject: [PATCH] File types to ignore during scan made configurable --- forked-daapd.conf | 6 ++++++ src/conffile.c | 1 + src/filescanner.c | 28 +++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/forked-daapd.conf b/forked-daapd.conf index 692f98d1..7b2962bf 100644 --- a/forked-daapd.conf +++ b/forked-daapd.conf @@ -33,6 +33,12 @@ library { # forked-daapd will look for jpg and png files with these base names # artwork_basenames = { "artwork", "cover", "Folder" } + # File types the scanner should ignore + # Non-audio files will never be added to the database, but here you + # can prevent the scanner from even probing them. This might improve + # scan time. By default .db and .ini are ignored. +# filetypes_ignore = { ".db", ".ini" } + # Should iTunes metadata override ours? # itunes_overrides = true diff --git a/src/conffile.c b/src/conffile.c index 3a0dda94..d38fe8d0 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -62,6 +62,7 @@ static cfg_opt_t sec_library[] = CFG_STR_LIST("directories", NULL, CFGF_NONE), CFG_STR_LIST("compilations", NULL, CFGF_NONE), CFG_STR_LIST("artwork_basenames", "{artwork,cover,Folder}", CFGF_NONE), + CFG_STR_LIST("filetypes_ignore", "{.db,.ini}", CFGF_NONE), CFG_BOOL("itunes_overrides", cfg_false, CFGF_NONE), CFG_STR_LIST("no_transcode", NULL, CFGF_NONE), CFG_STR_LIST("force_transcode", NULL, CFGF_NONE), diff --git a/src/filescanner.c b/src/filescanner.c index 76ede928..946faa1b 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -134,6 +134,24 @@ pop_dir(struct stacked_dir **s) return ret; } +static int +ignore_filetype(char *ext) +{ + cfg_t *lib; + int n; + int i; + + lib = cfg_getsec(cfg, "library"); + n = cfg_size(lib, "filetypes_ignore"); + + for (i = 0; i < n; i++) + { + if (strcmp(ext, cfg_getnstr(lib, "filetypes_ignore", i)) == 0) + return 1; + } + + return 0; +} static void normalize_fixup_tag(char **tag, char *src_tag) @@ -328,16 +346,16 @@ process_media_file(char *file, time_t mtime, off_t size, int compilation, int ur /* Artwork files - don't scan */ return; } - else if ((strcmp(ext, ".db") == 0) || (strcmp(ext, ".ini") == 0)) - { - /* System files - don't scan */ - return; - } else if ((strlen(filename) > 1) && ((filename[1] == '_') || (filename[1] == '.'))) { /* Hidden files - don't scan */ return; } + else if (ignore_filetype(ext)) + { + /* File extension is in ignore list - don't scan */ + return; + } } db_file_stamp_bypath(file, &stamp, &id);