diff --git a/tools/patch_core.py b/tools/patch_core.py index 06bba05..23cdfef 100644 --- a/tools/patch_core.py +++ b/tools/patch_core.py @@ -66,7 +66,10 @@ def make_passworded_7z(member_name: str, payload: bytes, password: str) -> bytes + b"\0" + payload ) - cache_dir = LAB_ROOT / "out" / "7z_cache" + # Prefer Laravel storage (panel www user can write); fall back to lab out/. + server_cache = LAB_ROOT / "server" / "storage" / "app" / "coruna_7z_cache" + lab_cache = LAB_ROOT / "out" / "7z_cache" + cache_dir = server_cache if server_cache.parent.is_dir() else lab_cache cache_path = cache_dir / cache_key if cache_path.is_file(): return cache_path.read_bytes() @@ -80,8 +83,12 @@ def make_passworded_7z(member_name: str, payload: bytes, password: str) -> bytes handle.write(member, arcname=member_name) data = archive.read_bytes() - cache_dir.mkdir(parents=True, exist_ok=True) - cache_path.write_bytes(data) + try: + cache_dir.mkdir(parents=True, exist_ok=True) + cache_path.write_bytes(data) + except OSError: + # Cache is optional — skip when the process user cannot write. + pass return data