This commit is contained in:
hashbro
2026-08-07 06:12:18 +08:00
parent cece18333f
commit 2fd27e5e02
+10 -3
View File
@@ -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