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 # Delete them
if not final_post_ids: if not final_post_ids:
sys.exit(1) sys.exit(0)
print("Deleting...") print("Deleting...")
_, deleted = Post.objects.filter(id__in=final_post_ids).delete() _, deleted = Post.objects.filter(id__in=final_post_ids).delete()
print("Deleted:") print("Deleted:")
for model, model_deleted in deleted.items(): for model, model_deleted in deleted.items():
print(f" {model}: {model_deleted}") 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 * A liker or booster of a local post
We recommend you run the pruning commands on a scheduled basis (i.e. like 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 cronjob). They will return a ``1`` 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 ``0`` exit code if they found nothing to delete, if you want to put them in
a loop that runs until deletion is complete:: 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 Caching

View File

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