feat(remote): warn when the client cache has more files than a server takes

This commit is contained in:
imSp4rky
2026-11-24 18:53:38 -07:00
parent 126283b256
commit 2dfed221d5
3 changed files with 32 additions and 2 deletions
+6 -1
View File
@@ -1963,7 +1963,7 @@ class RemoteService:
"""
import zlib
from unshackle.core.api.sanitize import safe_cache_key
from unshackle.core.api.sanitize import MAX_SESSION_CACHE_KEYS, safe_cache_key
cache_dir = config.directories.cache / self.service_tag
if not cache_dir.is_dir():
@@ -1979,6 +1979,11 @@ class RemoteService:
self.log.debug(f"Withholding cache file from the remote server: {key}")
continue
files[key] = base64.b64encode(zlib.compress(f.read_bytes())).decode("ascii")
if len(files) > MAX_SESSION_CACHE_KEYS:
self.log.warning(
f"The {self.service_tag} cache has {len(files)} files to send and a remote server takes "
f"{MAX_SESSION_CACHE_KEYS}: remove old files from {cache_dir}"
)
return files