Skip to content

Commit

Permalink
avoid nonexistent source file breaking vfs due to stat error
Browse files Browse the repository at this point in the history
  • Loading branch information
azuline committed Mar 9, 2024
1 parent fdb8813 commit 1d6a748
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rose/virtualfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,12 @@ def stat(mode: Literal["dir", "file"], realpath: Path | None = None) -> dict[str
attrs["st_mtime_ns"] = 0.0
attrs["st_ctime_ns"] = 0.0
if realpath:
s = realpath.stat()
attrs["st_size"] = s.st_size
attrs["st_atime_ns"] = s.st_atime
attrs["st_mtime_ns"] = s.st_mtime
attrs["st_ctime_ns"] = s.st_ctime
with contextlib.suppress(FileNotFoundError):
s = realpath.stat()
attrs["st_size"] = s.st_size
attrs["st_atime_ns"] = s.st_atime
attrs["st_mtime_ns"] = s.st_mtime
attrs["st_ctime_ns"] = s.st_ctime

return attrs

Expand Down

0 comments on commit 1d6a748

Please sign in to comment.