From fd47ede5d06b87f4e96aedd091bebc5a7e44dc33 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Tue, 12 Dec 2023 10:16:45 +0100 Subject: [PATCH] don't go to loading screen if file is cached --- src/herald/web.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/herald/web.py b/src/herald/web.py index 91f79c9..3fb996c 100644 --- a/src/herald/web.py +++ b/src/herald/web.py @@ -226,6 +226,9 @@ async def async_get_file() -> Tuple[IO[bytes], str]: ) is_cached = gh.is_artifact_cached(f"{owner}/{repo}", artifact_id) + is_file_cached = gh.is_file_cached( + f"{owner}/{repo}", artifact_id, file, to_png + ) is_htmx = "HX-Request" in request.headers @@ -236,7 +239,12 @@ async def async_get_file() -> Tuple[IO[bytes], str]: "We think this is a browser request based on Accept header %s", request.headers.get("Accept"), ) - if is_cached or not is_browser or not config.ENABLE_LOADING_PAGE: + if ( + is_cached + or is_file_cached + or not is_browser + or not config.ENABLE_LOADING_PAGE + ): logger.debug("File is cached, call and return immediately") buf, mime = await async_get_file() response = await make_response(buf.read())