This commit is contained in:
2026-01-14 18:23:20 -08:00
parent f40d0b61a2
commit bcc1353d0b
2 changed files with 32 additions and 4 deletions

View File

@@ -288,7 +288,7 @@ class ZeroTier(Store):
url += f"{sep}api_key={self._api_key}"
return url
def download_to_temp(self, file_hash: str, temp_root: Optional[Path] = None) -> Optional[Path]:
def download_to_temp(self, file_hash: str, temp_root: Optional[Path] = None, suffix: Optional[str] = None) -> Optional[Path]:
"""Download a file from the remote peer to a local temporary file."""
import os
import httpx
@@ -301,13 +301,19 @@ class ZeroTier(Store):
if not url or not isinstance(url, str) or not url.startswith("http"):
return None
# Ensure suffix starts with a dot if provided
if suffix and not suffix.startswith("."):
suffix = f".{suffix}"
if not suffix:
suffix = ".tmp"
try:
# Use provided temp_root or system temp
if temp_root:
temp_root.mkdir(parents=True, exist_ok=True)
fd, tmp_path = tempfile.mkstemp(dir=str(temp_root), suffix=".tmp")
fd, tmp_path = tempfile.mkstemp(dir=str(temp_root), suffix=suffix)
else:
fd, tmp_path = tempfile.mkstemp(suffix=".tmp")
fd, tmp_path = tempfile.mkstemp(suffix=suffix)
os_fd = os.fdopen(fd, 'wb')