[cli/downloader.mp] Explicitly set UTF-8 encoding for resume/repair file

Fixes #297
This commit is contained in:
derrod 2021-09-28 02:42:17 +02:00
parent e881e42d5f
commit b319cb505c
2 changed files with 4 additions and 4 deletions

View file

@ -932,7 +932,7 @@ class LegendaryCLI:
# always write repair file, even if all match
if repair_file:
repair_filename = os.path.join(self.core.lgd.get_tmp_path(), f'{args.app_name}.repair')
with open(repair_filename, 'w') as f:
with open(repair_filename, 'w', encoding='utf-8') as f:
f.write('\n'.join(repair_file))
logger.debug(f'Written repair file to "{repair_filename}"')

View file

@ -113,7 +113,7 @@ class DLManager(Process):
mismatch = 0
completed_files = set()
for line in open(self.resume_file).readlines():
for line in open(self.resume_file, encoding='utf-8').readlines():
file_hash, _, filename = line.strip().partition(':')
_p = os.path.join(self.dl_dir, filename)
if not os.path.exists(_p):
@ -527,8 +527,8 @@ class DLManager(Process):
file_hash = self.hash_map[res.filename]
# write last completed file to super simple resume file
with open(self.resume_file, 'ab') as rf:
rf.write(f'{file_hash}:{res.filename}\n'.encode('utf-8'))
with open(self.resume_file, 'a', encoding='utf-8') as rf:
rf.write(f'{file_hash}:{res.filename}\n')
if not res.success:
# todo make this kill the installation process or at least skip the file and mark it as failed