diff --git a/backend/app/pypi_proxy.py b/backend/app/pypi_proxy.py index 164995f..6502824 100644 --- a/backend/app/pypi_proxy.py +++ b/backend/app/pypi_proxy.py @@ -451,20 +451,14 @@ async def pypi_download_file( content = response.content content_type = response.headers.get('content-type', 'application/octet-stream') - # Compute hash - sha256 = hashlib.sha256(content).hexdigest() - size = len(content) + # Store in S3 (computes hash and deduplicates automatically) + from io import BytesIO + result = storage.store(BytesIO(content)) + sha256 = result.sha256 + size = result.size logger.info(f"PyPI proxy: downloaded {filename}, {size} bytes, sha256={sha256[:12]}") - # Store in S3 - from io import BytesIO - artifact = storage.store_artifact( - file_obj=BytesIO(content), - filename=filename, - content_type=content_type, - ) - # Check if artifact already exists existing = db.query(Artifact).filter(Artifact.id == sha256).first() if existing: