Skip to content

Commit

Permalink
Fixes Tribler#7473 FileNotFoundError when displaying the settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky committed Jun 11, 2023
1 parent c80f825 commit d46dbea
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/tribler/core/utilities/path_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ def size(self, include_dir_sizes: bool = True) -> int:
for root, dir_names, file_names in os.walk(self):
names = itertools.chain(dir_names, file_names) if include_dir_sizes else file_names
paths = (os.path.join(root, name) for name in names)
size += sum(os.path.getsize(p) for p in paths if os.path.exists(p))
for p in paths:
if os.path.exists(p):
try:
size += os.path.getsize(p)
except FileNotFoundError:
# In rare cases of race condition, it is possible that the file,
# such as `sqlite/knowledge.db-journal`, was deleted right after the `os.path.exists` check.
pass
return size

def startswith(self, text: str) -> bool:
Expand Down

0 comments on commit d46dbea

Please sign in to comment.