Repository navigation
perf(utils): use std::fs::remove_dir_all() - #5204
Conversation
There was a problem hiding this comment.
Can you do a little git blame stuff to try and figure out why rustup started using the remove_dir_all crate? Presumably this predated the inclusion of this function in std?
I don't think your manual testing should be a prerequisite to using this on Windows -- we should just start using it everywhere (does that mean we don't need the raw helper anymore?) and see if Windows CI passes.
ee0d990 to
ed0718e
Compare
std::fs::remove_dir_all()
Sure :) I adjusted the PR so it uses std everywhere. Git Blame history:
|
Can you look at why it started using its own code on Unix? |
tbh I couldn't find the reason for why they changed it. The commit message and changelog give no reason for dropping the std re-export. The code that needed the security fix was the two functions std doesn't have. My guess is that they wanted one handle-based implementation behind every entry point. For the record, the 0.8 changelog also says:
That supports the point that std's function is fine for rustup, which isn't a setuid binary. @rbtcollins made the same point in #3244 |
|
Shouldn't we completely remove our use of the |
On macOS and Linux, the
remove_dir_allcrate opens every entry it deletes to find out whether it's a directory. Endpoint security software scans files on open, so that becomes one scan per file. On my Mac with suhc a endpoint software, rustup toolchain uninstall of a nightly with the docs took 11 minutes. This does not happen when using the stdfs::remove_dir_all:)remove_dir_all1.0rustup toolchain uninstall, macOS with Defender, 72,597 entriesI couldn't test windows and AFAIK the remove_dir_all does some speedup optimizations here. Would be interesting if we could switch windows to the std version as well