cache archive keys generated in __contains__() (#524)

To avoid writing a different key to the archive than what was checked
against before the file download.
pull/552/head
Mike Fährmann 5 years ago
parent bf658fd84b
commit 58391d492d
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -748,13 +748,13 @@ class DownloadArchive():
def __contains__(self, kwdict):
"""Return True if the item described by 'kwdict' exists in archive"""
key = self.keygen(kwdict)
key = kwdict["_archive_key"] = self.keygen(kwdict)
self.cursor.execute(
"SELECT 1 FROM archive WHERE entry=? LIMIT 1", (key,))
return self.cursor.fetchone()
def add(self, kwdict):
"""Add item described by 'kwdict' to archive"""
key = self.keygen(kwdict)
key = kwdict.get("_archive_key") or self.keygen(kwdict)
self.cursor.execute(
"INSERT OR IGNORE INTO archive VALUES (?)", (key,))

Loading…
Cancel
Save