Skip to content

Commit

Permalink
More paranoid delete
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-finley committed Aug 31, 2024
1 parent 682be36 commit a86bf1c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions queue_files/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,15 @@ def run(event, context):
if dropbox_result.has_more:
publisher.publish(QUEUE_TOPIC_NAME, "Hi".encode("utf-8"))

# Delete all but the newest cursor
# Delete cursors older than the most recent one (ok if new writes come in while this is running)
with conn.cursor() as cursor:
cursor.execute(
"""
DELETE FROM dropbox_cursors
WHERE dropbox_cursor NOT IN (
SELECT dropbox_cursor
WHERE created_at < (
SELECT MAX(created_at)
FROM dropbox_cursors
ORDER BY created_at DESC
LIMIT 1
);
)
"""
)
Expand Down

0 comments on commit a86bf1c

Please sign in to comment.