make OSErrors during file downloads nonfatal (closes #512)

… except ENOSPC (No space left on device), since there is no reason to
continue downloading in that case.

All other errors that would prevent downloading data and writing it to
disk get already raised during directory creation and are therefore not
checked here.
This commit is contained in:
Mike Fährmann
2019-12-18 22:08:53 +01:00
parent d0920e84e9
commit 1921c127a5

View File

@@ -8,6 +8,7 @@
import sys
import time
import errno
import logging
from . import extractor, downloader, postprocessor
from . import config, text, util, output, exception
@@ -292,7 +293,13 @@ class DownloadJob(Job):
scheme = url.partition(":")[0]
downloader = self.get_downloader(scheme)
if downloader:
return downloader.download(url, self.pathfmt)
try:
return downloader.download(url, self.pathfmt)
except OSError as exc:
if exc.errno == errno.ENOSPC:
raise
self.log.warning("%s: %s", exc.__class__.__name__, exc)
return False
self._write_unsupported(url)
return False