pmb.chroot.zap: don't calculate size (MR 2252)

It's nice to know how much space gets free'd when zapping, but I often
find myself with a lot of chroot's and other junk, and on my laptop
running "du" across all of this takes quite a few seconds. As this is
purely cosmetic, it doesn't justify taking such a long time.

Remove the size calculation code to substantially speed up zap.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-05-19 15:29:19 +02:00 committed by Oliver Smith
parent a76cd92bcb
commit b31dee9ec3
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
import glob import glob
import logging import logging
import math
import os import os
import pmb.chroot import pmb.chroot
@ -37,8 +36,6 @@ def zap(args, confirm=True, dry=False, pkgs_local=False, http=False,
# Get current work folder size # Get current work folder size
if not dry: if not dry:
pmb.chroot.shutdown(args) pmb.chroot.shutdown(args)
logging.debug("Calculate work folder size")
size_old = pmb.helpers.other.folder_size(args, args.work)
# Delete packages with a different version compared to aports, # Delete packages with a different version compared to aports,
# then re-index # then re-index
@ -89,10 +86,6 @@ def zap(args, confirm=True, dry=False, pkgs_local=False, http=False,
# Print amount of cleaned up space # Print amount of cleaned up space
if dry: if dry:
logging.info("Dry run: nothing has been deleted") logging.info("Dry run: nothing has been deleted")
else:
size_new = pmb.helpers.other.folder_size(args, args.work)
mb = (size_old - size_new) / 1024
logging.info(f"Cleared up ~{math.ceil(mb)} MB of space")
def zap_pkgs_local_mismatch(args, confirm=True, dry=False): def zap_pkgs_local_mismatch(args, confirm=True, dry=False):