Only expire KeyConfirmationQueue items that haven't been confirmed

This commit is contained in:
Piotr F. Mieszkowski 2024-04-12 12:13:12 +02:00
parent abd3f923fb
commit c92b9aed80
Signed by: pfm
GPG key ID: BDE5BC1FA5DC53D5

View file

@ -175,7 +175,14 @@ class KeyConfirmationQueue:
def delete_expired_queue_items(self, older_than: datetime): def delete_expired_queue_items(self, older_than: datetime):
"""Remove keys that have been in queue before `older_than`.""" """Remove keys that have been in queue before `older_than`."""
delq = delete(self._keys).where(self._keys.c.time < older_than) delq = delete(self._keys) \
.where(
and_(
self._keys.c.time < older_than,
# We only want to delete keys that haven't been confirmed.
self._keys.c.confirm != db.CO_CONFIRMED
)
)
LOG.debug('Deleting queue items older than %s: %s', repr(older_than), delq) LOG.debug('Deleting queue items older than %s: %s', repr(older_than), delq)
with self._engine.connect() as conn: with self._engine.connect() as conn: