From 1921c127a52cc472b558352b1502d5f08403392e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 18 Dec 2019 22:08:53 +0100 Subject: [PATCH] make OSErrors during file downloads nonfatal (closes #512) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … 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. --- gallery_dl/job.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gallery_dl/job.py b/gallery_dl/job.py index 7932cd0a..88b6a55e 100644 --- a/gallery_dl/job.py +++ b/gallery_dl/job.py @@ -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