Skip to content

Commit

Permalink
don't go to loading screen if file is cached
Browse files Browse the repository at this point in the history
  • Loading branch information
paulgessinger committed Dec 12, 2023
1 parent 92acc1f commit fd47ede
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/herald/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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())
Expand Down

0 comments on commit fd47ede

Please sign in to comment.