Moved hishel cache directory into spoolmans data directory

This is to prevent permission issues
This commit is contained in:
Donkie
2024-05-21 11:25:08 +02:00
parent 0ab6e92d65
commit 620febc3ab
3 changed files with 12 additions and 10 deletions

View File

@@ -12,6 +12,7 @@ from pydantic import BaseModel, Field
from scheduler.asyncio.scheduler import Scheduler
from spoolman import filecache
from spoolman.env import get_cache_dir
logger = logging.getLogger(__name__)
@@ -21,12 +22,13 @@ DEFAULT_SYNC_INTERVAL = 3600
controller = hishel.Controller(allow_stale=True)
try:
cache_storage = hishel.AsyncFileStorage()
cache_path = get_cache_dir() / "hishel"
cache_storage = hishel.AsyncFileStorage(base_path=cache_path)
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()),
str(cache_path.resolve()),
)
cache_storage = hishel.AsyncInMemoryStorage()