mirror of
https://github.com/owntone/owntone-server.git
synced 2025-05-05 09:16:38 -04:00
Add option to exclude paths from scanning based on regex
This commit is contained in:
parent
baa3ee63ca
commit
4df4c50c35
@ -40,6 +40,7 @@ AC_CHECK_HEADERS([sys/wait.h])
|
|||||||
AC_CHECK_HEADERS([sys/param.h])
|
AC_CHECK_HEADERS([sys/param.h])
|
||||||
AC_CHECK_HEADERS([sys/select.h])
|
AC_CHECK_HEADERS([sys/select.h])
|
||||||
AC_CHECK_HEADERS([dirent.h])
|
AC_CHECK_HEADERS([dirent.h])
|
||||||
|
AC_CHECK_HEADERS([regex.h])
|
||||||
AC_CHECK_FUNCS(posix_fadvise)
|
AC_CHECK_FUNCS(posix_fadvise)
|
||||||
AC_CHECK_FUNCS(strptime)
|
AC_CHECK_FUNCS(strptime)
|
||||||
AC_CHECK_FUNCS(strtok_r)
|
AC_CHECK_FUNCS(strtok_r)
|
||||||
|
@ -102,6 +102,12 @@ library {
|
|||||||
# scan time. By default .db, .ini, .db-journal and .pdf are ignored.
|
# scan time. By default .db, .ini, .db-journal and .pdf are ignored.
|
||||||
# filetypes_ignore = { ".db", ".ini", ".db-journal", ".pdf" }
|
# filetypes_ignore = { ".db", ".ini", ".db-journal", ".pdf" }
|
||||||
|
|
||||||
|
# File paths the scanner should ignore
|
||||||
|
# If you want to exclude files on a more advanced basis you can enter
|
||||||
|
# one or more POSIX regular expressions, and any file with a matching
|
||||||
|
# path will be ignored.
|
||||||
|
# filepath_ignore = { "myregex" }
|
||||||
|
|
||||||
# Disable startup file scanning
|
# Disable startup file scanning
|
||||||
# When forked-daapd starts it will do an initial file scan of your
|
# When forked-daapd starts it will do an initial file scan of your
|
||||||
# library (and then watch it for changes). If you are sure your library
|
# library (and then watch it for changes). If you are sure your library
|
||||||
@ -109,7 +115,7 @@ library {
|
|||||||
# initial file scan and save some system ressources. Disabling this scan
|
# initial file scan and save some system ressources. Disabling this scan
|
||||||
# may lead to forked-daapd's database coming out of sync with the
|
# may lead to forked-daapd's database coming out of sync with the
|
||||||
# library. If that happens read the instructions in the README on how
|
# library. If that happens read the instructions in the README on how
|
||||||
# to trigger a full rescan.
|
# to trigger a rescan.
|
||||||
# filescan_disable = false
|
# filescan_disable = false
|
||||||
|
|
||||||
# Should iTunes metadata override ours?
|
# Should iTunes metadata override ours?
|
||||||
|
@ -78,6 +78,7 @@ static cfg_opt_t sec_library[] =
|
|||||||
CFG_STR_LIST("artwork_basenames", "{artwork,cover,Folder}", CFGF_NONE),
|
CFG_STR_LIST("artwork_basenames", "{artwork,cover,Folder}", CFGF_NONE),
|
||||||
CFG_BOOL("artwork_individual", cfg_false, CFGF_NONE),
|
CFG_BOOL("artwork_individual", cfg_false, CFGF_NONE),
|
||||||
CFG_STR_LIST("filetypes_ignore", "{.db,.ini,.db-journal,.pdf}", CFGF_NONE),
|
CFG_STR_LIST("filetypes_ignore", "{.db,.ini,.db-journal,.pdf}", CFGF_NONE),
|
||||||
|
CFG_STR_LIST("filepath_ignore", NULL, CFGF_NONE),
|
||||||
CFG_BOOL("filescan_disable", cfg_false, CFGF_NONE),
|
CFG_BOOL("filescan_disable", cfg_false, 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),
|
||||||
|
@ -53,6 +53,10 @@
|
|||||||
# include <sys/eventfd.h>
|
# include <sys/eventfd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_REGEX_H
|
||||||
|
# include <regex.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
@ -172,6 +176,43 @@ pop_dir(struct stacked_dir **s)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_REGEX_H
|
||||||
|
/* Checks if the file path is configured to be ignored */
|
||||||
|
static int
|
||||||
|
file_path_ignore(const char *path)
|
||||||
|
{
|
||||||
|
cfg_t *lib;
|
||||||
|
regex_t regex;
|
||||||
|
int n;
|
||||||
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
lib = cfg_getsec(cfg, "library");
|
||||||
|
n = cfg_size(lib, "filepath_ignore");
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
ret = regcomp(®ex, cfg_getnstr(lib, "filepath_ignore", i), 0);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_SCAN, "Could not compile regex for matching with file path\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = regexec(®ex, path, 0, NULL, 0);
|
||||||
|
regfree(®ex);
|
||||||
|
|
||||||
|
if (ret == 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_DBG, L_SCAN, "Regex match: %s\n", path);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Checks if the file extension is in the ignore list */
|
/* Checks if the file extension is in the ignore list */
|
||||||
static int
|
static int
|
||||||
file_type_ignore(const char *ext)
|
file_type_ignore(const char *ext)
|
||||||
@ -203,6 +244,11 @@ file_type_get(const char *path) {
|
|||||||
else
|
else
|
||||||
filename++;
|
filename++;
|
||||||
|
|
||||||
|
#ifdef HAVE_REGEX_H
|
||||||
|
if (file_path_ignore(path))
|
||||||
|
return FILE_IGNORE;
|
||||||
|
#endif
|
||||||
|
|
||||||
ext = strrchr(path, '.');
|
ext = strrchr(path, '.');
|
||||||
if (!ext || (strlen(ext) == 1))
|
if (!ext || (strlen(ext) == 1))
|
||||||
return FILE_REGULAR;
|
return FILE_REGULAR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user