[fix] favicons: don't hard code settings folder to /etc/searxng

The location of the local settings depends on environment ``SEARXNG_SETTINGS_PATH``
and can be different from ``/etc/searxng``.  Issue was reported on Matrix [1].

To get the location function ``searx.settings_loader.get_user_cfg_folder()``
should be used.

[1] https://matrix.to/#/!vxScbLNEAmRvOraXBn:matrix.org/$5xNMYvONGB-mPt2B3ttoL27QncRFhkjGkO-TISdmP08?via=matrix.org&via=tchncs.de&via=envs.net

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2024-10-22 09:05:00 +02:00 committed by Markus Heiser
parent 050451347b
commit b14d885f23

View file

@ -22,8 +22,9 @@ def init():
# pylint: disable=import-outside-toplevel # pylint: disable=import-outside-toplevel
from . import config, cache, proxy from . import config, cache, proxy
from .. import settings_loader
cfg_file = pathlib.Path("/etc/searxng/favicons.toml") cfg_file = (settings_loader.get_user_cfg_folder() or pathlib.Path("/etc/searxng")) / "favicons.toml"
if not cfg_file.exists(): if not cfg_file.exists():
if is_active(): if is_active():
logger.error(f"missing favicon config: {cfg_file}") logger.error(f"missing favicon config: {cfg_file}")
@ -34,4 +35,4 @@ def init():
cache.init(cfg.cache) cache.init(cfg.cache)
proxy.init(cfg.proxy) proxy.init(cfg.proxy)
del cache, config, proxy, cfg del cache, config, proxy, cfg, settings_loader