filesystem: in recursive mtime, check only files that exist#32175
Merged
haampie merged 2 commits intospack:developfrom Aug 16, 2022
Merged
filesystem: in recursive mtime, check only files that exist#32175haampie merged 2 commits intospack:developfrom
haampie merged 2 commits intospack:developfrom
Conversation
When a `develop` path contains a dead symlink, the `os.stat` in the recursive `mtime` determination trips up over it. This ensures that the recursive `mtime` only `stat`s existing files. Closes spack#32165.
Member
|
You should use |
wdconinc
commented
Aug 16, 2022
Contributor
Author
|
Another 70 |
Member
|
Another implementation is class MaxMtimeVisitor(BaseDirectoryVisitor):
def __init__(self):
self.max_mtime = 0
def visit_file(self, root, rel_path, depth):
t = os.lstat(os.path.join(root, rel_path)).st_mtime
if t > self.max_mtime:
self.max_mtime = t
def visit_symlinked_file(self, root, rel_path, depth):
self.visit_file(root, rel_path, depth)
def before_visit_dir(self, root, rel_path, depth):
return True
def before_visit_symlinked_dir(self, root, rel_path, depth):
return False
def last_modification_time_recursive(path):
visitor = MaxMtimeVisitor()
visit_directory_tree(path, visitor)
return visitor.max_mtimeIf you wanna make it faster in general you could also consider skipping |
haampie
approved these changes
Aug 16, 2022
Contributor
Author
I want it not to throw an error :-) |
haampie
pushed a commit
that referenced
this pull request
Aug 17, 2022
* filesystem: use lstat in recursive mtime When a `develop` path contains a dead symlink, the `os.stat` in the recursive `mtime` determination trips up over it. Closes #32165.
haampie
pushed a commit
that referenced
this pull request
Aug 18, 2022
* filesystem: use lstat in recursive mtime When a `develop` path contains a dead symlink, the `os.stat` in the recursive `mtime` determination trips up over it. Closes #32165.
ma595
pushed a commit
to ma595/spack
that referenced
this pull request
Sep 13, 2022
) * filesystem: use lstat in recursive mtime When a `develop` path contains a dead symlink, the `os.stat` in the recursive `mtime` determination trips up over it. Closes spack#32165.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a
developpath contains a dead symlink, theos.statin the recursivemtimedetermination trips up over it. This ensures that the recursivemtimeonlystats existing files.Closes #32165.