fix: abschliessen.py zeigt kleine Dateien in Byte statt „0 KB“
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
775560a64c
commit
d66f185fdd
1 changed files with 6 additions and 3 deletions
|
|
@ -119,9 +119,12 @@ def deletion_blockers(folder):
|
|||
|
||||
|
||||
def size(path):
|
||||
"""Size of a file or folder, readable: "830 B", "17 KB"."""
|
||||
if path.is_file():
|
||||
return path.stat().st_size
|
||||
return sum(p.stat().st_size for p in path.rglob("*") if p.is_file())
|
||||
total = path.stat().st_size
|
||||
else:
|
||||
total = sum(p.stat().st_size for p in path.rglob("*") if p.is_file())
|
||||
return f"{total} B" if total < 1024 else f"{total / 1024:.0f} KB"
|
||||
|
||||
|
||||
def confirm(question):
|
||||
|
|
@ -229,7 +232,7 @@ def main():
|
|||
|
||||
print(f"\nArbeitsordner {folder}:")
|
||||
for entry in sorted(folder.iterdir()):
|
||||
print(f" {entry.name}{'/' if entry.is_dir() else ''} ({size(entry) / 1024:.0f} KB)")
|
||||
print(f" {entry.name}{'/' if entry.is_dir() else ''} ({size(entry)})")
|
||||
if not args.ja and not confirm(f"Arbeitsordner {folder} löschen? [j/N] "):
|
||||
print("Nicht gelöscht.")
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue