Skip to content

Commit

Permalink
make OSErrors during file downloads nonfatal (closes #512)
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
mikf committed Dec 19, 2019
1 parent d0920e8 commit 1921c12
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gallery_dl/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import sys
import time
import errno
import logging
from . import extractor, downloader, postprocessor
from . import config, text, util, output, exception
Expand Down Expand Up @@ -292,7 +293,13 @@ def download(self, url):
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

Expand Down

0 comments on commit 1921c12

Please sign in to comment.