From 0620d473c2df34d02137fb22c23fb0f166b0e1a1 Mon Sep 17 00:00:00 2001 From: NRK Date: Thu, 20 Jun 2024 10:50:19 +0000 Subject: allow {white,black}listing thumbnail cache dirs (#461) this adds the cli flags --cache-{allow,deny} along with corresponding config.h vars which allows the user to control which directories will have thumbnail cache written. this is a more general version of the `cache-whitelist` patch that existed in the nsxiv-extra repo: https://codeberg.org/nsxiv/nsxiv-extra/src/commit/21cb27cee7/patches/cache-whitelist Closes: https://codeberg.org/nsxiv/nsxiv/issues/454 --- options.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'options.c') diff --git a/options.c b/options.c index 4ae2ea5..b813244 100644 --- a/options.c +++ b/options.c @@ -75,7 +75,9 @@ void parse_options(int argc, char **argv) OPT_START = UCHAR_MAX, OPT_AA, OPT_AL, - OPT_BG + OPT_BG, + OPT_CA, + OPT_CD }; static const struct optparse_long longopts[] = { { "framerate", 'A', OPTPARSE_REQUIRED }, @@ -105,6 +107,8 @@ void parse_options(int argc, char **argv) { "alpha-layer", OPT_AL, OPTPARSE_OPTIONAL }, /* TODO: document this when it's stable */ { "bg-cache", OPT_BG, OPTPARSE_OPTIONAL }, + { "cache-allow", OPT_CA, OPTPARSE_REQUIRED }, + { "cache-deny", OPT_CD, OPTPARSE_REQUIRED }, { 0 }, /* end */ }; @@ -137,6 +141,8 @@ void parse_options(int argc, char **argv) _options.geometry = NULL; _options.res_name = NULL; + _options.tns_filters = TNS_FILTERS; + _options.tns_filters_is_blacklist = TNS_FILTERS_IS_BLACKLIST; _options.quiet = false; _options.thumb_mode = false; _options.clean_cache = false; @@ -266,6 +272,10 @@ void parse_options(int argc, char **argv) error(EXIT_FAILURE, 0, "Invalid argument for option --bg-cache: %s", op.optarg); _options.background_cache = op.optarg == NULL; break; + case OPT_CA: case OPT_CD: + _options.tns_filters = op.optarg; + _options.tns_filters_is_blacklist = (opt == OPT_CD); + break; } } -- cgit v1.2.3-70-g09d2