[downloader:http] don't overwrite existing '_mtime' fields
This commit is contained in:
@@ -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():
|
||||||
|
|||||||
Reference in New Issue
Block a user