remove temp files before downloading from fallback URLs

otherwise the next call to download() with a fallback URL could see
the partially downloaded "remains" from the previous, failed download
attempt and "continue" it, writing the second half of a potentially
different version of that file.
pull/586/head
Mike Fährmann 5 years ago
parent 760b9b4db4
commit 0b84068d84
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015-2019 Mike Fährmann # Copyright 2015-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
@ -209,6 +209,7 @@ class DownloadJob(Job):
# use fallback URLs if available # use fallback URLs if available
for num, url in enumerate(fallback or (), 1): for num, url in enumerate(fallback or (), 1):
util.remove_file(self.temppath)
self.log.info("Trying fallback URL #%d", num) self.log.info("Trying fallback URL #%d", num)
if self.download(url): if self.download(url):
break break

Loading…
Cancel
Save