1
0
mirror of https://github.com/venthur/blag.git synced 2025-11-25 12:42:41 +00:00

ignoe FileNotFound Error that sometimes happens when getting mtime of directories

Fixes: #231
This commit is contained in:
Bastian Venthur
2024-10-11 11:09:32 +02:00
parent 8fed4894ee
commit 0d03733b4f
2 changed files with 8 additions and 1 deletions

View File

@@ -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

View File

@@ -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