File types to ignore during scan made configurable

This commit is contained in:
ejurgensen 2013-10-26 20:59:05 +02:00
parent 55db599c5e
commit 766177bf10
3 changed files with 30 additions and 5 deletions

View File

@ -33,6 +33,12 @@ library {
# forked-daapd will look for jpg and png files with these base names # forked-daapd will look for jpg and png files with these base names
# artwork_basenames = { "artwork", "cover", "Folder" } # 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? # Should iTunes metadata override ours?
# itunes_overrides = true # itunes_overrides = true

View File

@ -62,6 +62,7 @@ static cfg_opt_t sec_library[] =
CFG_STR_LIST("directories", NULL, CFGF_NONE), CFG_STR_LIST("directories", NULL, CFGF_NONE),
CFG_STR_LIST("compilations", NULL, CFGF_NONE), CFG_STR_LIST("compilations", NULL, CFGF_NONE),
CFG_STR_LIST("artwork_basenames", "{artwork,cover,Folder}", 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_BOOL("itunes_overrides", cfg_false, CFGF_NONE),
CFG_STR_LIST("no_transcode", NULL, CFGF_NONE), CFG_STR_LIST("no_transcode", NULL, CFGF_NONE),
CFG_STR_LIST("force_transcode", NULL, CFGF_NONE), CFG_STR_LIST("force_transcode", NULL, CFGF_NONE),

View File

@ -134,6 +134,24 @@ pop_dir(struct stacked_dir **s)
return ret; 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 static void
normalize_fixup_tag(char **tag, char *src_tag) 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 */ /* Artwork files - don't scan */
return; 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] == '.'))) else if ((strlen(filename) > 1) && ((filename[1] == '_') || (filename[1] == '.')))
{ {
/* Hidden files - don't scan */ /* Hidden files - don't scan */
return; return;
} }
else if (ignore_filetype(ext))
{
/* File extension is in ignore list - don't scan */
return;
}
} }
db_file_stamp_bypath(file, &stamp, &id); db_file_stamp_bypath(file, &stamp, &id);