From 8213fa8508023249b7b26647675af25aa9e83aaf Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Sat, 29 Jul 2023 21:14:34 -0700 Subject: [PATCH] Fix md5 dedup check, add debug message when a post is being added to the database Signed-off-by: Alek Ratzloff --- chanbans/pull.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/chanbans/pull.py b/chanbans/pull.py index 752e9dc..8cde9bb 100644 --- a/chanbans/pull.py +++ b/chanbans/pull.py @@ -86,7 +86,6 @@ async def pull(): # Try to create post in database try: with db: - # Check the last N bans for the given board. If the following columns are equal: # * now # * time @@ -102,16 +101,23 @@ async def pull(): where now = :now and time = :time - and md5 = :md5 + and (md5 = :md5 or md5 is null) and com = :com and sub = :sub and board = :board """, post, ) - if _row := result.fetchone(): - log.debug("duplicate found, skipping - %s", _row["id"]) + if row := result.fetchone(): + log.debug("duplicate found, skipping - %s", row["id"]) continue + else: + log.debug( + "adding post from %s with creation time %s and ban time %s", + post["board"], + post["time"], + post["now"], + ) post["action"] = cols["action"] # post['board'] = cols['board']