Fix error handling for local files in :adblock-update

This commit is contained in:
Florian Bruhin 2015-01-09 06:53:00 +01:00
parent 4c1113cdf4
commit 5947994479

View File

@ -112,7 +112,7 @@ class HostBlocker:
"Run :adblock-update to get adblock lists.")
@cmdutils.register(instance='host-blocker')
def adblock_update(self):
def adblock_update(self, win_id: {'special': 'win_id'}):
"""Update the adblock block lists."""
self.blocked_hosts = set()
self._done_count = 0
@ -125,8 +125,10 @@ class HostBlocker:
if url.scheme() == 'file':
try:
fileobj = open(url.path(), 'rb')
except OSError:
log.misc.exception("Failed to open block list!")
except OSError as e:
message.error(win_id, "adblock: Error while reading {}: "
"{}".format(url.path(), e.strerror))
continue
download = FakeDownload(fileobj)
self._in_progress.append(download)
self.on_download_finished(download)