Moved hishel cache directory into spoolmans data directory
This is to prevent permission issues
This commit is contained in:
@@ -264,6 +264,11 @@ def get_backups_dir() -> Path:
|
|||||||
return backups_dir
|
return backups_dir
|
||||||
|
|
||||||
|
|
||||||
|
def get_cache_dir() -> Path:
|
||||||
|
"""Get the cache directory."""
|
||||||
|
return get_data_dir() / "cache"
|
||||||
|
|
||||||
|
|
||||||
def get_version() -> str:
|
def get_version() -> str:
|
||||||
"""Get the version of the package.
|
"""Get the version of the package.
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from pydantic import BaseModel, Field
|
|||||||
from scheduler.asyncio.scheduler import Scheduler
|
from scheduler.asyncio.scheduler import Scheduler
|
||||||
|
|
||||||
from spoolman import filecache
|
from spoolman import filecache
|
||||||
|
from spoolman.env import get_cache_dir
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -21,12 +22,13 @@ DEFAULT_SYNC_INTERVAL = 3600
|
|||||||
|
|
||||||
controller = hishel.Controller(allow_stale=True)
|
controller = hishel.Controller(allow_stale=True)
|
||||||
try:
|
try:
|
||||||
cache_storage = hishel.AsyncFileStorage()
|
cache_path = get_cache_dir() / "hishel"
|
||||||
|
cache_storage = hishel.AsyncFileStorage(base_path=cache_path)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Failed to setup disk-based cache due to permission error. Ensure the path %s is writable. "
|
"Failed to setup disk-based cache due to permission error. Ensure the path %s is writable. "
|
||||||
"Using in-memory cache instead as fallback.",
|
"Using in-memory cache instead as fallback.",
|
||||||
str(Path(".cache/hishel").resolve()),
|
str(cache_path.resolve()),
|
||||||
)
|
)
|
||||||
cache_storage = hishel.AsyncInMemoryStorage()
|
cache_storage = hishel.AsyncInMemoryStorage()
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,12 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from spoolman.env import get_data_dir
|
from spoolman.env import get_cache_dir
|
||||||
|
|
||||||
|
|
||||||
def _get_cache_dir() -> Path:
|
|
||||||
"""Get the cache directory."""
|
|
||||||
return get_data_dir() / "cache"
|
|
||||||
|
|
||||||
|
|
||||||
def get_file(name: str) -> Path:
|
def get_file(name: str) -> Path:
|
||||||
"""Get the path to a file."""
|
"""Get the path to a file in the cache dir."""
|
||||||
return _get_cache_dir() / name
|
return get_cache_dir() / name
|
||||||
|
|
||||||
|
|
||||||
def update_file(name: str, data: bytes) -> None:
|
def update_file(name: str, data: bytes) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user