[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 self.downloading = False
if self.mtime: 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 return True
def receive(self, response, file): def receive(self, response, file):

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

Loading…
Cancel
Save