-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Create FileManager
with a root and normalize filenames against it
#1881
Conversation
0620d5c
to
781f93b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really appreciate you doing this @phated, this looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting test failures if I swap out normalize_path
for std::fs:canonicalize
when using my alternative impl which only normalizes files which should exist. This seems odd so will going to take a little bit of an extra look before approving.
FileManager
with a root and normalize filenames against it
This looks good to me once all the conflicts are fixed. Took a look at addressing this myself but I'm not sure what the deal is with |
075cbb2
to
870c45d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Problem*
Resolves #1869
Resolves #1599 (this can still be cleaned up a bit by taking a reference & adding a lifetime to context)
Summary*
This changes the FileManager so that it requires a root when constructed. It then resolves the root against filenames passed to
add_file
and uses a customnormalize_path
function to resolve.
and..
in the resulting file paths. This avoids thecanonicalize
function which goes out to the filesystem and isunimplemented!()
in WASM.Since the FileManager must be constructed with a root, I've also removed the Default deriver and constructed
Context
manually in each location we need one.I've tried to think through all of the ramifications of this change, but I probably missed something that @TomAFrench will catch. Nevertheless, I think this is a step in the right direction because we aren't reliant on the
current_dir
of the running process.Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmt
on default settings.