From eedbc655ecb025b4687403906bddee25b25c4b83 Mon Sep 17 00:00:00 2001 From: Ben Hagen Date: Tue, 1 Sep 2020 14:53:54 +0200 Subject: [PATCH] Use glob to calculate folder size --- ocopy/utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ocopy/utils.py b/ocopy/utils.py index 79381d1..1dfcfa3 100644 --- a/ocopy/utils.py +++ b/ocopy/utils.py @@ -15,11 +15,9 @@ def wrapper(*args, **kwargs): def folder_size(path): total = 0 - for entry in os.scandir(path): + for entry in Path(path).glob("**/*"): if entry.is_file(): total += entry.stat().st_size - elif entry.is_dir(): - total += folder_size(entry.path) return total