From 324751eec5ee9da617bc0bdecaa6d771cf778f26 Mon Sep 17 00:00:00 2001 From: spacewander Date: Thu, 2 Jan 2020 15:27:29 +0800 Subject: [PATCH] Don't try to write down the image file if download failed --- safaribooks.py | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 safaribooks.py diff --git a/safaribooks.py b/safaribooks.py old mode 100644 new mode 100755 index 95c13a3..6514e26 --- a/safaribooks.py +++ b/safaribooks.py @@ -850,6 +850,7 @@ class SafariBooks: response = self.requests_provider(urljoin(SAFARI_BASE_URL, url), stream=True) if response == 0: self.display.error("Error trying to retrieve this image: %s\n From: %s" % (image_name, url)) + return with open(image_path, 'wb') as img: for chunk in response.iter_content(1024):