Don't try to write down the image file if download failed
This commit is contained in:
parent
aa46cfbc95
commit
324751eec5
1 changed files with 1 additions and 0 deletions
1
safaribooks.py
Normal file → Executable file
1
safaribooks.py
Normal file → Executable file
|
|
@ -850,6 +850,7 @@ class SafariBooks:
|
||||||
response = self.requests_provider(urljoin(SAFARI_BASE_URL, url), stream=True)
|
response = self.requests_provider(urljoin(SAFARI_BASE_URL, url), stream=True)
|
||||||
if response == 0:
|
if response == 0:
|
||||||
self.display.error("Error trying to retrieve this image: %s\n From: %s" % (image_name, url))
|
self.display.error("Error trying to retrieve this image: %s\n From: %s" % (image_name, url))
|
||||||
|
return
|
||||||
|
|
||||||
with open(image_path, 'wb') as img:
|
with open(image_path, 'wb') as img:
|
||||||
for chunk in response.iter_content(1024):
|
for chunk in response.iter_content(1024):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue