Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit980cc85

Browse files
committed
fix error in folder size calculator where files do not exist in some cases
1 parent4ce02df commit980cc85

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎general/calculate-directory-size/get_directory_size.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ def get_directory_size(directory):
2727
total+=entry.stat().st_size
2828
elifentry.is_dir():
2929
# if it's a directory, recursively call this function
30-
total+=get_directory_size(entry.path)
30+
try:
31+
total+=get_directory_size(entry.path)
32+
exceptFileNotFoundError:
33+
pass
3134
exceptNotADirectoryError:
3235
# if `directory` isn't a directory, get the file size then
3336
returnos.path.getsize(directory)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp