forked from github.com/blag
ignoe FileNotFound Error that sometimes happens when getting mtime of directories
Fixes: #231
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user