Skip to content

Commit

Permalink
ignoe FileNotFound Error that sometimes happens when getting mtime of…
Browse files Browse the repository at this point in the history
… directories

Fixes: #231
  • Loading branch information
venthur committed Oct 11, 2024
1 parent 8fed489 commit 0d03733
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [unreleased] --

* Ignore FileNotFoundError when trying to get the last modified time of files
in directories. This happens for example with temporary emacs files.
* Added changelog to docs
* removed ruff's target-version from pyproject.toml, this value defaults to the
projects requires-python
Expand Down
7 changes: 6 additions & 1 deletion blag/devserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ def get_last_modified(dirs: list[str]) -> float:
for dir in dirs:
for root, dirs, files in os.walk(dir):
for f in files:
mtime = os.stat(os.path.join(root, f)).st_mtime
try:
mtime = os.stat(os.path.join(root, f)).st_mtime
except FileNotFoundError:
# ignore files that have been deleted since the os.walk
# call (for example temporary emacs files)
continue
if mtime > last_mtime:
last_mtime = mtime

Expand Down

0 comments on commit 0d03733

Please sign in to comment.