Merge pull request #80 from Zeecka/main

Fix #78
This commit is contained in:
Zeecka
2025-06-16 20:00:53 +02:00
committed by GitHub
+5 -3
View File
@@ -40,16 +40,18 @@ def cleanup_old_entries() -> None:
else:
img_date = img.last_submission_date
delay = datetime.now(timezone.utc) - img_date
img_fold = RESULT_FOLDER / img.hash
if delay.total_seconds() > MAX_STORE_TIME:
for s in img.submissions:
db.session.delete(s) # type: ignore
shutil.rmtree(RESULT_FOLDER / img.hash) # type: ignore
if img_fold.exists():
shutil.rmtree(img_fold) # type: ignore
db.session.delete(img)
# Delete Images with missing submission
if len(img.submissions) == 0 and delay.total_seconds() > MAX_PENDING_TIME:
shutil.rmtree(RESULT_FOLDER / img.hash) # type: ignore
if img_fold.exists():
shutil.rmtree(img_fold) # type: ignore
db.session.delete(img)
db.session.commit()