for file in files:
filename = os.path.join(SOURCE_CACHE_DIR, file)
- if os.path.exists(filename):
+ if os.path.exists(filename) and os.path.getsize(filename):
existant_files.append(filename)
else:
download_files.append(filename)
os.makedirs(SOURCE_CACHE_DIR)
for filename in download_files:
+ self.grabber.urlgrab(os.path.basename(filename), filename=filename)
+
try:
self.grabber.urlgrab(os.path.basename(filename), filename=filename)
except URLGrabError, e:
raise DownloadError, "%s %s" % (os.path.basename(filename), e)
+ # Check if the downloaded file was empty.
+ if os.path.getsize(filename) == 0:
+ # Remove the file and raise an error.
+ os.unlink(filename)
+
+ raise DownloadError, _("Downloaded empty file: %s") \
+ % os.path.basename(filename)
+
log.info("")
return existant_files + download_files