Merge branch 'develop' into feature/days-rework

This commit is contained in:
Jörn-Michael Miehe 2023-09-12 06:36:12 +00:00
commit a84323afc8

View file

@ -1,3 +1,4 @@
import asyncio
import re
from io import BytesIO
@ -29,7 +30,12 @@ class WebDAV:
Liste aller Dateien im Ordner `directory`, die zur RegEx `regex` passen
"""
ls = cls._webdav_client.list(directory)
loop = asyncio.get_running_loop()
ls = await loop.run_in_executor(
None,
cls._webdav_client.list,
directory,
)
return [f"{directory}/{path}" for path in ls if regex.search(path)]
@ -40,7 +46,12 @@ class WebDAV:
`True`, wenn an Pfad `path` eine Datei existiert
"""
return cls._webdav_client.check(path)
loop = asyncio.get_running_loop()
return await loop.run_in_executor(
None,
cls._webdav_client.check,
path,
)
@classmethod
@(_rb_ttl := AsyncTTL(time_to_live=SETTINGS.webdav.cache_ttl, skip_args=1))
@ -50,7 +61,12 @@ class WebDAV:
"""
buffer = BytesIO()
cls._webdav_client.resource(path).write_to(buffer)
loop = asyncio.get_running_loop()
await loop.run_in_executor(
None,
cls._webdav_client.resource(path).write_to,
buffer,
)
buffer.seek(0)
return buffer.read()
@ -69,7 +85,12 @@ class WebDAV:
Bytes `buffer` in Datei in Pfad `path` schreiben
"""
cls._webdav_client.resource(path).read_from(buffer)
loop = asyncio.get_running_loop()
await loop.run_in_executor(
None,
cls._webdav_client.resource(path).read_from,
buffer,
)
try:
# hack: zugehörigen Cache-Eintrag entfernen