Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race in FileResponse if file is replaced during prepare #10101

Merged
merged 17 commits into from
Dec 4, 2024
Prev Previous commit
Next Next commit
comments
  • Loading branch information
bdraco committed Dec 4, 2024
commit caeac0f2e02e1a790b9db07cf05a3eedf4753be2
6 changes: 4 additions & 2 deletions aiohttp/web_fileresponse.py
Original file line number Diff line number Diff line change
@@ -184,7 +184,9 @@ def _open_file_path_stat_encoding(
st = compressed_path.lstat()
if S_ISREG(st.st_mode):
fobj = compressed_path.open("rb")
with suppress(OSError):
with suppress(
OSError
): # fstat() may not be available on all platforms
# Once we open the file, we want the fstat() to ensure
# the file has not changed between the first stat()
# and the open().
@@ -196,7 +198,7 @@ def _open_file_path_stat_encoding(
if not S_ISREG(st.st_mode):
return None, st, None
fobj = file_path.open("rb")
with suppress(OSError):
with suppress(OSError): # fstat() may not be available on all platforms
# Once we open the file, we want the fstat() to ensure
# the file has not changed between the first stat()
# and the open().
Loading