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