Move cover cache and temp files from /tmp to XDG cache (~/.cache/neo-pod-desktop/)

- Add xdg_cache_path() utility respecting
- CoverCache now stores covers in ~/.cache/neo-pod-desktop/covers/
- MetadataHandler temp files in ~/.cache/neo-pod-desktop/thumbnails/
- Survives reboot, no more lost cover_path during process_file
This commit is contained in:
Maksim Totmin
2026-05-31 23:16:42 +07:00
parent 6a841afaa0
commit 8cc4ef5279
2 changed files with 18 additions and 7 deletions
+16 -4
View File
@@ -9,21 +9,33 @@ from __future__ import annotations
import hashlib
import logging
import os
import tempfile
logger = logging.getLogger(__name__)
def xdg_cache_path(subdir: str) -> str:
"""Return path inside XDG cache directory for neo-pod-desktop.
Creates the directory structure if missing.
"""
base = os.environ.get(
"XDG_CACHE_HOME",
os.path.join(os.path.expanduser("~"), ".cache"),
)
path = os.path.join(base, "neo-pod-desktop", subdir)
os.makedirs(path, exist_ok=True)
return path
class CoverCache:
"""Manages a local cache of cover art images for the player UI.
The cache stores JPEG thumbnails keyed by (artist, album) hash.
Covers are stored in $XDG_CACHE_HOME/neo-pod-desktop/covers/
(default ~/.cache/neo-pod-desktop/covers/).
"""
def __init__(self, cache_dir: str | None = None):
self.cache_dir = cache_dir or os.path.join(
tempfile.gettempdir(), "neo-pod-covers"
)
self.cache_dir = cache_dir or xdg_cache_path("covers")
os.makedirs(self.cache_dir, exist_ok=True)
def _key(self, artist: str, album: str) -> str: