6

Detect filesystem loop during walking the projects by weihanglo · Pull Request #...

 2 years ago
source link: https://github.com/rust-lang/cargo/pull/10188
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

Author

weihanglo commented on Dec 10, 2021

Running cargo doc in root after this fix looks like:

root@4145378fddab:/# ./project/target/debug/cargo doc
error: failed to determine package fingerprint for documenting foo v0.1.0 (/)

Caused by:
  failed to determine the most recently modified file in /

Caused by:
  failed to determine list of files in /

Caused by:
  cannot read "/proc/1/cwd"

Caused by:
  filesystem loop detected: `/proc/1/cwd` links to an ancestor `/`

I've tried using walkdir but found it hard to avoid multple calls on fs::metadata. This is the one with minimal changes I can think of at this moment. I notice that in walkdir, it introduces struct Ancestor to avoid slow open file ops on Windows. Should we need to do the same thing?

For removing unnecessary collect for some calls on PathSource::list_files, I found it not simple to convert it into callback/iterator flavor. The list_files_git is more complex . Will find a time to refactor it if possible.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK