Skip to content

Commit

Permalink
Use glob to calculate folder size
Browse files Browse the repository at this point in the history
  • Loading branch information
cbenhagen committed Sep 1, 2020
1 parent b8dd705 commit eedbc65
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions ocopy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit eedbc65

Please sign in to comment.