about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2011-09-03 11:32:05 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2011-09-03 11:32:05 +0200
commitdbddab27992fa609102d512a7762ae8f5b39c55c (patch)
tree172a9e61ef3cd8695001467b05c090ef45bb0755
parent802622ac1c76ddd2ede5899a62601c15cf8a18e3 (diff)
downloadyoutube-dl-dbddab27992fa609102d512a7762ae8f5b39c55c.tar.gz
youtube-dl-dbddab27992fa609102d512a7762ae8f5b39c55c.tar.xz
youtube-dl-dbddab27992fa609102d512a7762ae8f5b39c55c.zip
Robust error handling in downloading code
-rwxr-xr-xyoutube-dl4
1 files changed, 4 insertions, 0 deletions
diff --git a/youtube-dl b/youtube-dl
index 68c9bc429..3f45e92f2 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -930,6 +930,7 @@ class FileDownloader(object):
 			if stream is None:
 				try:
 					(stream, tmpfilename) = sanitize_open(tmpfilename, open_mode)
+					assert stream is not None
 					filename = self.undo_temp_name(tmpfilename)
 					self.report_destination(filename)
 				except (OSError, IOError), err:
@@ -951,6 +952,9 @@ class FileDownloader(object):
 			# Apply rate limit
 			self.slow_down(start, byte_counter - resume_len)
 
+		if stream is None:
+			self.trouble(u'\nERROR: Did not get any data blocks')
+			return False
 		stream.close()
 		self.report_finish()
 		if data_len is not None and byte_counter != data_len: