1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 12:12:34 +01:00

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.
This commit is contained in:
Mike Fährmann 2019-12-20 16:43:08 +01:00
parent bf658fd84b
commit 58391d492d
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -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,))