We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4ce02df commit 980cc85Copy full SHA for 980cc85
general/calculate-directory-size/get_directory_size.py
@@ -27,7 +27,10 @@ def get_directory_size(directory):
27
total += entry.stat().st_size
28
elif entry.is_dir():
29
# if it's a directory, recursively call this function
30
- total += get_directory_size(entry.path)
+ try:
31
+ total += get_directory_size(entry.path)
32
+ except FileNotFoundError:
33
+ pass
34
except NotADirectoryError:
35
# if `directory` isn't a directory, get the file size then
36
return os.path.getsize(directory)
0 commit comments