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