[downloader:http] don't overwrite existing '_mtime' fields

pull/726/head
Mike Fährmann 5 years ago
parent dc65f7d8dc
commit 38bc6430d3
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -164,7 +164,11 @@ class HttpDownloader(DownloaderBase):
self.downloading = False
if self.mtime:
pathfmt.kwdict["_mtime"] = response.headers.get("Last-Modified")
pathfmt.kwdict.setdefault(
"_mtime", response.headers.get("Last-Modified"))
else:
pathfmt.kwdict["_mtime"] = None
return True
def receive(self, response, file):

@ -840,16 +840,15 @@ class PathFormat():
shutil.copyfile(self.temppath, self.realpath)
os.unlink(self.temppath)
if "_mtime" in self.kwdict:
mtime = self.kwdict.get("_mtime")
if mtime:
# Set file modification time
mtime = self.kwdict["_mtime"]
if mtime:
try:
if isinstance(mtime, str):
mtime = mktime_tz(parsedate_tz(mtime))
os.utime(self.realpath, (time.time(), mtime))
except Exception:
pass
try:
if isinstance(mtime, str):
mtime = mktime_tz(parsedate_tz(mtime))
os.utime(self.realpath, (time.time(), mtime))
except Exception:
pass
class DownloadArchive():

Loading…
Cancel
Save