fix partial downloads for 'text:' URLs

Using a filesize in bytes as offset into a Python string is not
a good idea if said file contains non-ASCII characters.
This commit is contained in:
Mike Fährmann
2017-10-25 15:04:45 +02:00
parent 239d7afea7
commit 9a41002b77
2 changed files with 8 additions and 9 deletions

View File

@@ -16,7 +16,6 @@ import logging
class DownloaderBase():
"""Base class for downloaders"""
retries = 1
mode = "b"
part = True
def __init__(self, session, output):
@@ -66,13 +65,13 @@ class DownloaderBase():
# check response
if not offset:
mode = "w" + self.mode
mode = "wb"
if filesize:
self.log.info("Unable to resume partial download")
elif offset == -1:
break # early finish
else:
mode = "a" + self.mode
mode = "ab"
self.log.info("Resuming download at byte %d", offset)
# set missing filename extension