From 82a38e6bd053cde2a83526e2ed10e8dd26aaed22 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Mon, 13 Nov 2023 19:22:12 +0000 Subject: [PATCH] Check cookie file exists --- linkcheck/command/setup_config.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/linkcheck/command/setup_config.py b/linkcheck/command/setup_config.py index 3f7a1210..5d7e6a51 100644 --- a/linkcheck/command/setup_config.py +++ b/linkcheck/command/setup_config.py @@ -202,8 +202,11 @@ def setup_config(config, options): if options.useragent is not None: config["useragent"] = options.useragent if options.cookiefile is not None: - if fileutil.is_readable(options.cookiefile): - config["cookiefile"] = options.cookiefile - else: + if not fileutil.is_valid_config_source(options.cookiefile): + log.error( + LOG_CMDLINE, _("Cookie file %s does not exist."), options.cookiefile) + elif not fileutil.is_readable(options.cookiefile): msg = _("Could not read cookie file %s") % options.cookiefile log.error(LOG_CMDLINE, msg) + else: + config["cookiefile"] = options.cookiefile