diff --git a/proxy_scraper_checker/geodb.py b/proxy_scraper_checker/geodb.py index ca3864d..c5c18c0 100644 --- a/proxy_scraper_checker/geodb.py +++ b/proxy_scraper_checker/geodb.py @@ -1,5 +1,6 @@ from __future__ import annotations +import asyncio import logging import stat from typing import Optional @@ -28,6 +29,10 @@ async def _read_etag() -> Optional[str]: return bytes_decode(content) +def _remove_etag() -> asyncio.Future[None]: + return asyncify(GEODB_ETAG_PATH.unlink)(missing_ok=True) + + async def _save_etag(etag: str, /) -> None: await fs.async_add_permission( GEODB_ETAG_PATH, stat.S_IWUSR, missing_ok=True @@ -85,3 +90,5 @@ async def download_geodb(*, progress: Progress, session: ClientSession) -> None: if etag := response.headers.get(hdrs.ETAG): await _save_etag(etag) + else: + await _remove_etag()