From f9b720e2e1bd652f15662d9a1fa772c5c017fa6c Mon Sep 17 00:00:00 2001 From: lluni Date: Tue, 1 Aug 2023 19:18:49 +0200 Subject: [PATCH] Add break condition in cleanup script --- cleanup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cleanup.py b/cleanup.py index 43bca62..5778ac9 100644 --- a/cleanup.py +++ b/cleanup.py @@ -36,6 +36,10 @@ for i in range(5): # default: check 5 batches of 40 posts # get next batch of posts last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, max_id=id_oldest_of_last_posts, limit=40) + # break if there are no more posts + if len(last_posts) == 0: + break + # delete all old posts of the current batch for submission in last_posts: # if post has no favorites, boosts or replies, delete it