Fix minor errors in the new thumbnail stuff was stopping stuff from being inserted

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2023-02-19 01:09:46 -08:00
parent 26a17f7bbc
commit 02324c78ab

View File

@@ -135,23 +135,27 @@ async def main():
if 'thumb' in post:
thumb_path = Path(THUMBS_DIR, f"{post['thumb']}s.jpg")
download_jobs += [get_thumb(thumb_path, post)]
else:
thumb_path = ""
# Try to create post in database
try:
with db:
curs = db.execute(
"insert into bans (action, board, length, post, thumb_path, reason) values(?, ?, ?, ?, ?)",
"insert into bans (action, board, length, post, thumb_path, reason) values(?, ?, ?, ?, ?, ?)",
(
cols["action"],
cols["board"],
cols["length"],
json.dumps(cols["post"]),
cols["thumb_path"],
str(thumb_path),
cols["reason"],
),
)
except:
pass
except Exception as ex:
msg = str(ex)
if 'UNIQUE' not in msg:
print("error:", ex)
# Finish off thumbnail jobs
await asyncio.gather(*download_jobs)