diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a3ba767..94f23cc 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -93,7 +93,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: error-screenshots - path: ./errors + path: ./errors/* # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker diff --git a/main.py b/main.py index 1ceb5cd..7958342 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio import logging import time +from pathlib import Path import uvicorn import uvicorn.config @@ -39,7 +40,10 @@ async def read_item(request: LinkRequest): try: challenged = await asyncio.wait_for(bypass_cloudflare(page), timeout=timeout) except asyncio.TimeoutError as e: - await page.save_screenshot("errors/error.png") + i = 0 + while Path(f"errors/error{i}.png").is_file(): + i += 1 + await page.save_screenshot(f"errors/error{i}.png") raise HTTPException(detail="Timeout", status_code=408) from e logger.info(f"Got webpage: {request.url}")