Skip to content

Commit

Permalink
Add logging to pupa clean failsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
msj committed Aug 3, 2023
1 parent 21d36c2 commit 8fdc8d3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pupa/cli/commands/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ def handle(self, args, other):
)
self.report_stale_objects()
else:
num_stale_objects = len(list(self.get_stale_objects(args.window)))
stale_objects = list(self.get_stale_objects(args.window))
num_stale_objects = len(stale_objects)

if args.noinput:
# Fail-safe to avoid deleting a large amount of objects
# without explicit confimation
if num_stale_objects > 10:
print(
"This command would delete more than 10 objects."
"If you're sure, re-run without --noinput to provide confirmation."
f"This command would delete {num_stale_objects} objects: "
f"\n{stale_objects}"
"\nIf you're sure, re-run without --noinput to provide confirmation."
)
sys.exit(1)
else:
Expand Down

0 comments on commit 8fdc8d3

Please sign in to comment.