Skip to content

Commit

Permalink
Update file_cache.py
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Grainger <[email protected]>
  • Loading branch information
woodruffw and graingert authored Nov 9, 2024
1 parent 05e1119 commit 51d816d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cachecontrol/caches/file_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ def _write(self, path: str, data: bytes) -> None:
with self.lock_class(path + ".lock"):
# Write our actual file
(fd, name) = tempfile.mkstemp(dir=dirname)
os.write(fd, data)
os.close(fd)
try:
os.write(fd, data)
finally:
os.close(fd)
os.chmod(name, self.filemode)
os.replace(name, path)

Expand Down

0 comments on commit 51d816d

Please sign in to comment.