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:
parent
bf658fd84b
commit
58391d492d
@ -748,13 +748,13 @@ class DownloadArchive():
|
|||||||
|
|
||||||
def __contains__(self, kwdict):
|
def __contains__(self, kwdict):
|
||||||
"""Return True if the item described by 'kwdict' exists in archive"""
|
"""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(
|
self.cursor.execute(
|
||||||
"SELECT 1 FROM archive WHERE entry=? LIMIT 1", (key,))
|
"SELECT 1 FROM archive WHERE entry=? LIMIT 1", (key,))
|
||||||
return self.cursor.fetchone()
|
return self.cursor.fetchone()
|
||||||
|
|
||||||
def add(self, kwdict):
|
def add(self, kwdict):
|
||||||
"""Add item described by 'kwdict' to archive"""
|
"""Add item described by 'kwdict' to archive"""
|
||||||
key = self.keygen(kwdict)
|
key = kwdict.get("_archive_key") or self.keygen(kwdict)
|
||||||
self.cursor.execute(
|
self.cursor.execute(
|
||||||
"INSERT OR IGNORE INTO archive VALUES (?)", (key,))
|
"INSERT OR IGNORE INTO archive VALUES (?)", (key,))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user