]> git.ipfire.org Git - location/libloc.git/commitdiff
python: Fix download of database
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 19 Nov 2020 12:03:33 +0000 (12:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 19 Nov 2020 12:03:33 +0000 (12:03 +0000)
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 <michael.tremer@ipfire.org>
src/python/downloader.py
src/python/location.in

index 87bbb685043677f6a4a21689abd3c34aa3ce6295..05f7872d1ff59b409c5c961e7362882c7d911888 100644 (file)
@@ -119,8 +119,8 @@ class Downloader(object):
 
                headers = {}
                if timestamp:
 
                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)
                        )
 
                t = tempfile.NamedTemporaryFile(dir=tmpdir, delete=False)
@@ -195,7 +195,7 @@ class Downloader(object):
                db = Database(f.name)
 
                # Database is not recent
                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(
                        return False
 
                log.info("Downloaded new database from %s" % (time.strftime(
index 6885ea02b5765c4a8d1973162eed5ba9a76bdb56..b30beae0f1a859bad546bef6c27c590c536d6832 100644 (file)
@@ -433,7 +433,7 @@ class CLI(object):
 
                # Try downloading a new database
                try:
 
                # 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:
 
                # If no file could be downloaded, log a message
                except FileNotFoundError as e: