Added permission error catch for setting up hishel cache

This commit is contained in:
Donkie
2024-05-21 00:00:10 +02:00
parent 4eee6712c1
commit 59295a3e5a

View File

@@ -13,13 +13,22 @@ from scheduler.asyncio.scheduler import Scheduler
from spoolman import filecache
logger = logging.getLogger(__name__)
DEFAULT_EXTERNAL_DB_URL = "https://donkie.github.io/SpoolmanDB/"
DEFAULT_SYNC_INTERVAL = 3600
controller = hishel.Controller(allow_stale=True)
try:
cache_storage = hishel.AsyncFileStorage()
logger = logging.getLogger(__name__)
except PermissionError:
logger.warning(
"Failed to setup disk-based cache due to permission error. Ensure the path %s is writable. "
"Using in-memory cache instead as fallback.",
str(Path(".cache/hishel").resolve()),
)
cache_storage = hishel.AsyncInMemoryStorage()
class SpoolType(Enum):