From: Michael Tremer Date: Thu, 19 Nov 2020 12:03:33 +0000 (+0000) Subject: python: Fix download of database X-Git-Tag: 0.9.5~49 X-Git-Url: http://git.ipfire.org/?p=location%2Flibloc.git;a=commitdiff_plain;h=2a550d12208f8bc8002e05ac08613312df26b20e python: Fix download of database This was all messed up in 0c74f6b1a3bdce5ebdc2ee452b9baf3e421dd3d1 when the change of type for the timestamp wasn't changed everywhere else. Signed-off-by: Michael Tremer --- diff --git a/src/python/downloader.py b/src/python/downloader.py index 87bbb68..05f7872 100644 --- a/src/python/downloader.py +++ b/src/python/downloader.py @@ -119,8 +119,8 @@ class Downloader(object): headers = {} if timestamp: - headers["If-Modified-Since"] = timestamp.strftime( - "%a, %d %b %Y %H:%M:%S GMT", + headers["If-Modified-Since"] = time.strftime( + "%a, %d %b %Y %H:%M:%S GMT", time.gmtime(timestamp), ) t = tempfile.NamedTemporaryFile(dir=tmpdir, delete=False) @@ -195,7 +195,7 @@ class Downloader(object): db = Database(f.name) # Database is not recent - if timestamp and db.created_at < timestamp.timestamp(): + if timestamp and db.created_at < timestamp: return False log.info("Downloaded new database from %s" % (time.strftime( diff --git a/src/python/location.in b/src/python/location.in index 6885ea0..b30beae 100644 --- a/src/python/location.in +++ b/src/python/location.in @@ -433,7 +433,7 @@ class CLI(object): # Try downloading a new database try: - t = d.download(public_key=ns.public_key, timestamp=timestamp, tmpdir=tmpdir) + t = d.download(public_key=ns.public_key, timestamp=t, tmpdir=tmpdir) # If no file could be downloaded, log a message except FileNotFoundError as e: