From 0a084946a368e915dbddfbee36bece46d8d54007 Mon Sep 17 00:00:00 2001 From: lluni Date: Wed, 2 Aug 2023 19:29:36 +0200 Subject: [PATCH] Add another return condition in cleanup script --- cleanup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cleanup.py b/cleanup.py index 851b263..323b2cb 100644 --- a/cleanup.py +++ b/cleanup.py @@ -26,6 +26,9 @@ def cleanup(limit: int = 40, id: int | None = None): last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, limit=limit) id_oldest_of_last_posts = -1 for _ in range(4): + # return if there are no posts to check + if len(last_posts) == 0: + return id_oldest_of_last_posts = last_posts[-1]["id"] last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, max_id=id_oldest_of_last_posts, limit=limit) else: