-
Notifications
You must be signed in to change notification settings - Fork 184
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
refactor: improve path handling in iroh dir #1345
Conversation
f3f52a8
to
1b28e82
Compare
pub fn env_path(self) -> Result<PathBuf> { | ||
let mut root = iroh_data_root()?; | ||
if !root.is_absolute() { | ||
root = std::env::current_dir()?.join(root); |
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.
shouldn't this use https://doc.rust-lang.org/std/path/struct.Path.html#method.canonicalize
instead?
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.
This comes from current main, I only copied it from src/commands/provide.rs
: /~https://github.com/n0-computer/iroh/pull/1345/files#diff-7de268e3454ececdfb93202f8f3bb012d38673ddcdca12fd5f7c5e2a6778dc5bL53
so dunno for sure. Does canonicalize
join to env::current_dir()
for relative paths? And - is that actually what we want?
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.
hmm, okay lets leave it as is for now
Ok(match s { | ||
"keypair" => Self::Keypair, | ||
"blobs.v0" => Self::BaoFlatStore, | ||
_ => bail!("unknown file or directory"), |
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.
would be good to have a basic test for this
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.
added a encode-parse roundtrip test
failure is unrelated (windows box fails to setup) |
Description
Currently the handling of paths and files within the IROH_DATA_DIR was a bit ad-hoc. This adds an enum in
config.rs
to only use well-defined paths.Notes & open questions
Change checklist
Tests if relevant.