Check cookie file exists

This commit is contained in:
Chris Mayo 2023-11-13 19:22:12 +00:00
parent db30833511
commit 82a38e6bd0

View file

@ -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