from __future__ import annotations import io import zipfile from pathlib import Path from paths import EXTENSION_DIR ZIP_FOLDER_NAME = "pts-session-sync" def build_extension_zip() -> bytes: if not EXTENSION_DIR.is_dir(): raise FileNotFoundError(f"Extension directory not found: {EXTENSION_DIR}") buffer = io.BytesIO() with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED) as archive: for path in sorted(EXTENSION_DIR.rglob("*")): if not path.is_file(): continue if path.name.startswith("."): continue arcname = Path(ZIP_FOLDER_NAME) / path.relative_to(EXTENSION_DIR) archive.write(path, arcname.as_posix()) return buffer.getvalue()