Invert pruning exit codes

This commit is contained in:
Andrew Godwin 2023-12-01 00:03:09 -07:00
parent 5f28d702f8
commit 837320f461
3 changed files with 7 additions and 5 deletions

View file

@ -73,10 +73,11 @@ class Command(BaseCommand):
# Delete them
if not final_post_ids:
sys.exit(1)
sys.exit(0)
print("Deleting...")
_, deleted = Post.objects.filter(id__in=final_post_ids).delete()
print("Deleted:")
for model, model_deleted in deleted.items():
print(f" {model}: {model_deleted}")
sys.exit(1)

View file

@ -128,11 +128,11 @@ Identity pruning removes any identity that isn't:
* A liker or booster of a local post
We recommend you run the pruning commands on a scheduled basis (i.e. like
a cronjob). They will return a ``0`` exit code if they deleted something and
a ``1`` exit code if they found nothing to delete, if you want to put them in
a cronjob). They will return a ``1`` exit code if they deleted something and
a ``0`` exit code if they found nothing to delete, if you want to put them in
a loop that runs until deletion is complete::
while ./manage.py pruneposts; do sleep 1; done
until ./manage.py pruneposts; do sleep 1; done
Caching

View file

@ -43,7 +43,7 @@ class Command(BaseCommand):
identity_ids = identities.values_list("id", flat=True)
print(f" found {len(identity_ids)}")
if not identity_ids:
sys.exit(1)
sys.exit(0)
# Delete them
print("Deleting...")
@ -51,3 +51,4 @@ class Command(BaseCommand):
print("Deleted:")
for model, model_deleted in deleted.items():
print(f" {model}: {model_deleted}")
sys.exit(1)