From 5979b4857c0acd6ff2735c7b87372acfc2ed7f7f Mon Sep 17 00:00:00 2001 From: Zeecka Date: Mon, 16 Jun 2025 19:59:20 +0200 Subject: [PATCH] Fix #78 --- aperisolve/cleanup.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aperisolve/cleanup.py b/aperisolve/cleanup.py index 309161c..130542d 100644 --- a/aperisolve/cleanup.py +++ b/aperisolve/cleanup.py @@ -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()