diff --git a/api/advent22_api/core/webdav.py b/api/advent22_api/core/webdav.py index 117b7b4..672a6ce 100644 --- a/api/advent22_api/core/webdav.py +++ b/api/advent22_api/core/webdav.py @@ -2,6 +2,7 @@ import re from io import BytesIO from cache import AsyncTTL +from cache.key import KEY from webdav3.client import Client as WebDAVclient from .settings import SETTINGS @@ -42,7 +43,7 @@ class WebDAV: return cls._webdav_client.check(path) @classmethod - @AsyncTTL(time_to_live=SETTINGS.webdav.cache_ttl, skip_args=1) + @(_rb_ttl := AsyncTTL(time_to_live=SETTINGS.webdav.cache_ttl, skip_args=1)) async def read_bytes(cls, path: str) -> bytes: """ Datei aus Pfad `path` als bytes laden @@ -70,6 +71,9 @@ class WebDAV: cls._webdav_client.resource(path).read_from(buffer) + # Cache-Eintrag entfernen (hack: siehe AsyncTTL._TTL.__contains__) + del cls._rb_ttl.ttl[KEY((path,), {})] + @classmethod async def write_str(cls, path: str, content: str, encoding="utf-8") -> None: """