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)
# Return temporary file
return t
+ # Delete the temporary file after unsuccessful downloads
+ os.unlink(t.name)
+
raise FileNotFoundError(url)
def _check_database(self, f, public_key, timestamp=None):
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(