refactor: delete all backup files, not just the latest
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -74,18 +74,21 @@ def delete(ctx):
|
|||||||
if not backup_files:
|
if not backup_files:
|
||||||
click.echo("No backup files found in ./backups")
|
click.echo("No backup files found in ./backups")
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
csv_file = backup_files[-1]
|
|
||||||
|
|
||||||
import csv as csv_mod
|
import csv as csv_mod
|
||||||
with open(csv_file, newline="") as f:
|
total = 0
|
||||||
count = sum(1 for _ in csv_mod.DictReader(f))
|
for f in backup_files:
|
||||||
|
with open(f, newline="") as fh:
|
||||||
|
total += sum(1 for _ in csv_mod.DictReader(fh))
|
||||||
|
click.echo(f" {f}")
|
||||||
|
|
||||||
click.echo(f"Will delete {count} orders from {csv_file}")
|
click.echo(f"Will delete {total} orders from {len(backup_files)} file(s)")
|
||||||
if not click.confirm("Continue?"):
|
if not click.confirm("Continue?"):
|
||||||
click.echo("Aborted")
|
click.echo("Aborted")
|
||||||
return
|
return
|
||||||
|
|
||||||
table = TableClient.from_connection_string(cfg.azure_connection_string, table_name="order")
|
table = TableClient.from_connection_string(cfg.azure_connection_string, table_name="order")
|
||||||
|
for csv_file in backup_files:
|
||||||
delete_orders(
|
delete_orders(
|
||||||
table_client=table,
|
table_client=table,
|
||||||
csv_path=csv_file,
|
csv_path=csv_file,
|
||||||
|
|||||||
Reference in New Issue
Block a user