Skip to content

Commit

Permalink
Merge pull request #1554 from henning-schild/henning/staging0
Browse files Browse the repository at this point in the history
hook: gracefully ignore non functional hooks and fall back to none
  • Loading branch information
pbiering authored Aug 7, 2024
2 parents 45f0b88 + 773f09f commit 2d0496b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions radicale/hook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
from typing import Sequence

from radicale import pathutils, utils
from radicale.log import logger

INTERNAL_TYPES: Sequence[str] = ("none", "rabbitmq")


def load(configuration):
"""Load the storage module chosen in configuration."""
return utils.load_plugin(
INTERNAL_TYPES, "hook", "Hook", BaseHook, configuration)
try:
return utils.load_plugin(
INTERNAL_TYPES, "hook", "Hook", BaseHook, configuration)
except Exception as e:
logger.warn(e)
logger.warn("Hook \"%s\" failed to load, falling back to \"none\"." % configuration.get("hook", "type"))
configuration = configuration.copy()
configuration.update({"hook": {"type": "none"}}, "hook", privileged=True)
return utils.load_plugin(
INTERNAL_TYPES, "hook", "Hook", BaseHook, configuration)


class BaseHook:
Expand Down

0 comments on commit 2d0496b

Please sign in to comment.