Merge pull request #1007 from JackDandy/feature/ChangeGetSizeNoDir

Change get_size to return zero for a dir that doesn't exist.
This commit is contained in:
JackDandy 2017-10-31 00:37:06 +00:00 committed by GitHub
commit 1a37bb1001
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1334,7 +1334,10 @@ def human(size):
def get_size(start_path='.'):
if ek.ek(os.path.isfile, start_path):
return ek.ek(os.path.getsize, start_path)
return sum(map((lambda x: x.stat(follow_symlinks=False).st_size), scantree(start_path)))
try:
return sum(map((lambda x: x.stat(follow_symlinks=False).st_size), scantree(start_path)))
except OSError:
return 0
def remove_article(text=''):