mirror of
https://github.com/venthur/blag.git
synced 2025-11-25 20:52:43 +00:00
ignoe FileNotFound Error that sometimes happens when getting mtime of directories
Fixes: #231
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
## [unreleased] --
|
## [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
|
* Added changelog to docs
|
||||||
* removed ruff's target-version from pyproject.toml, this value defaults to the
|
* removed ruff's target-version from pyproject.toml, this value defaults to the
|
||||||
projects requires-python
|
projects requires-python
|
||||||
|
|||||||
@@ -42,7 +42,12 @@ def get_last_modified(dirs: list[str]) -> float:
|
|||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
for root, dirs, files in os.walk(dir):
|
for root, dirs, files in os.walk(dir):
|
||||||
for f in files:
|
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:
|
if mtime > last_mtime:
|
||||||
last_mtime = mtime
|
last_mtime = mtime
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user