Set correct mtime of zip file

Since we are writing the zip file with python, the original mdate, on
which is_zip_uptodate() relies gets lost. Therefore overwrite it with
value of "Last-Modified" HTTP header
This commit is contained in:
2018-09-21 20:37:42 +02:00
parent 111fc38881
commit b14c0fa3a7

View File

@@ -24,6 +24,7 @@ import datetime
import zipfile
import shlex
import subprocess
import email.utils
import pywikibot
@@ -167,6 +168,15 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
shutil.copyfileobj(response, out_file)
# Extract original change date from http header
# We need to set it later, since we write a new file
mdate = email.utils.parsedate_to_datetime(
response.info()["Last-Modified"])
# Set ctime to value from http header
os.utime( os.path.join(self.wdir, type(self).zip_file),
(datetime.datetime.now().timestamp(), mdate.timestamp()) )
def extract_csv( self ):
"""
Extract csv file from zip archive