diff options
| author | Dennis Fink | 2026-11-13 20:13:54 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-13 20:13:54 +0100 |
| commit | 1f784f2b87ed0b2fd478e46d0d292c33f3150a3b (patch) | |
| tree | 7b74847c415916affb67e2c962da494ef64a29d2 /webmentions_ssg/tasks/extension.py | |
| parent | db7748111141d9d103f335fb8a0c647bce78b2cc (diff) | |
| download | webmentions-ssg-1f784f2b87ed0b2fd478e46d0d292c33f3150a3b.tar.gz webmentions-ssg-1f784f2b87ed0b2fd478e46d0d292c33f3150a3b.zip | |
fix(core): clarify Huey file path semantics
Document and test SQLAlchemy-style slash handling for file and SQLite
Huey URLs, including distinct relative and absolute path forms.
Update validation errors to show the supported three- and four-slash
conventions.
Diffstat (limited to '')
| -rw-r--r-- | webmentions_ssg/tasks/extension.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/webmentions_ssg/tasks/extension.py b/webmentions_ssg/tasks/extension.py index 029de68..2e78cc0 100644 --- a/webmentions_ssg/tasks/extension.py +++ b/webmentions_ssg/tasks/extension.py @@ -204,7 +204,9 @@ class Huey: def backend_from_url(url: str) -> tuple[type[BaseHuey], dict[str, Any]]: """Determine the Huey backend and storage options from a URL. - :param url: Huey backend URL. + :param url: Huey backend URL. SQLite and file paths use SQLAlchemy's + slash convention: three slashes for relative paths and four for + absolute paths (not RFC 8089 file-URI semantics). :return: Huey backend class and keyword arguments for its storage backend. :raises RuntimeError: If the URL is malformed for the selected backend or uses an unsupported scheme. @@ -240,9 +242,11 @@ class Huey: if not url.startswith(prefix): raise RuntimeError( - "SQLite Huey URLs must look like sqlite:///var/huey.db" + "SQLite Huey URLs must look like sqlite:///huey.db (relative) " + "or sqlite:////var/huey.db (absolute)" ) + # Preserve a leading slash only when the URL has four slashes. filename = url.removeprefix(prefix) if not filename: @@ -257,9 +261,11 @@ class Huey: if not url.startswith(prefix): raise RuntimeError( - "File Huey URLs must look like file:///var/huey-queue" + "File Huey URLs must look like file:///huey-queue (relative) " + "or file:////var/huey-queue (absolute)" ) + # file:////path is absolute; file:///path is relative here. path = url.removeprefix(prefix) if not path: |
