Commit initial

This commit is contained in:
2026-04-15 17:57:12 +02:00
parent 005d8e797e
commit 55516ee10f
269 changed files with 26854 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
# Storage package
Binary file not shown.
Binary file not shown.
+29
View File
@@ -0,0 +1,29 @@
"""Content-addressed file storage for driver packages."""
import hashlib
from pathlib import Path
class DriverStore:
"""SHA256 content-addressed file storage for printer driver packages.
Files are stored as DRIVERS_DIR/{sha256}.zip so identical uploads are
deduplicated automatically. The .zip suffix lets operators identify
stored driver packages by type when browsing the volume directly.
"""
def __init__(self, base_dir: str) -> None:
self._base = Path(base_dir)
self._base.mkdir(parents=True, exist_ok=True)
def save(self, data: bytes) -> str:
digest = hashlib.sha256(data).hexdigest()
dest = self.get_path(digest)
if not dest.exists():
dest.write_bytes(data)
return digest
def get_path(self, sha256: str) -> Path:
return self._base / f"{sha256}.zip"
def exists(self, sha256: str) -> bool:
return self.get_path(sha256).exists()