{
"event": "PreToolUse",
"tool_name": "Write",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/crawler\/src\/infrastructure\/storage\/file_storage.py",
"content": "from __future__ import annotations\n\nimport gzip\nimport pathlib\n\nfrom src.domain.ports.file_storage_port import FileStoragePort\n\n\nclass LocalFileStorage(FileStoragePort):\n def __init__(self, html_root: pathlib.Path, screenshot_root: pathlib.Path) -> None:\n self._html_root = html_root\n self._screenshot_root = screenshot_root\n\n def store_html(self, crawl_id: int, url_hash: str, payload: bytes) -> str:\n target = self._html_root \/ str(crawl_id) \/ f\"{_safe(url_hash)}.html.gz\"\n target.parent.mkdir(parents=True, exist_ok=True)\n target.write_bytes(gzip.compress(payload))\n return str(target)\n\n def store_screenshot(self, crawl_id: int, url_hash: str, payload: bytes) -> str:\n target = self._screenshot_root \/ str(crawl_id) \/ f\"{_safe(url_hash)}.png\"\n target.parent.mkdir(parents=True, exist_ok=True)\n target.write_bytes(payload)\n return str(target)\n\n\ndef _safe(url_hash: str) -> str:\n if len(url_hash) != 64 or not all(c in \"0123456789abcdef\" for c in url_hash):\n raise ValueError(f\"invalid url_hash: {url_hash!r}\")\n return url_hash\n"
}
}
{
"tool_response": {
"type": "create",
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/crawler\/src\/infrastructure\/storage\/file_storage.py",
"content": "from __future__ import annotations\n\nimport gzip\nimport pathlib\n\nfrom src.domain.ports.file_storage_port import FileStoragePort\n\n\nclass LocalFileStorage(FileStoragePort):\n def __init__(self, html_root: pathlib.Path, screenshot_root: pathlib.Path) -> None:\n self._html_root = html_root\n self._screenshot_root = screenshot_root\n\n def store_html(self, crawl_id: int, url_hash: str, payload: bytes) -> str:\n target = self._html_root \/ str(crawl_id) \/ f\"{_safe(url_hash)}.html.gz\"\n target.parent.mkdir(parents=True, exist_ok=True)\n target.write_bytes(gzip.compress(payload))\n return str(target)\n\n def store_screenshot(self, crawl_id: int, url_hash: str, payload: bytes) -> str:\n target = self._screenshot_root \/ str(crawl_id) \/ f\"{_safe(url_hash)}.png\"\n target.parent.mkdir(parents=True, exist_ok=True)\n target.write_bytes(payload)\n return str(target)\n\n\ndef _safe(url_hash: str) -> str:\n if len(url_hash) != 64 or not all(c in \"0123456789abcdef\" for c in url_hash):\n raise ValueError(f\"invalid url_hash: {url_hash!r}\")\n return url_hash\n",
"structuredPatch": [],
"originalFile": null,
"userModified": false
}
}