fix(playout): remove empty file when the download request failed (#2864)
This commit is contained in:
parent
72268ad9bb
commit
2facbfaff2
|
@ -50,13 +50,15 @@ class PypoFile(Thread):
|
|||
file_event.local_filepath,
|
||||
)
|
||||
try:
|
||||
with file_event.local_filepath.open("wb") as file_fd:
|
||||
try:
|
||||
with file_event.local_filepath.open("wb") as file_fd:
|
||||
response = self.api_client.download_file(file_event.id, stream=True)
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
file_fd.write(chunk)
|
||||
|
||||
except requests.exceptions.HTTPError as exception:
|
||||
file_event.local_filepath.unlink(missing_ok=True)
|
||||
|
||||
raise RuntimeError(
|
||||
f"could not download file {file_event.id}"
|
||||
) from exception
|
||||
|
|
Loading…
Reference in New Issue