Skip to content
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

Merged
merged 3 commits into from
Aug 12, 2023
Merged

refactor: improve path handling in iroh dir #1345

merged 3 commits into from
Aug 12, 2023

Conversation

Frando
Copy link
Member

@Frando Frando commented Aug 11, 2023

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

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.

@Frando Frando force-pushed the Frando/data-paths branch from f3f52a8 to 1b28e82 Compare August 11, 2023 11:10
pub fn env_path(self) -> Result<PathBuf> {
let mut root = iroh_data_root()?;
if !root.is_absolute() {
root = std::env::current_dir()?.join(root);
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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"),
Copy link
Contributor

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

Copy link
Member Author

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

@Frando
Copy link
Member Author

Frando commented Aug 11, 2023

failure is unrelated (windows box fails to setup)

@Frando Frando requested a review from dignifiedquire August 11, 2023 14:28
@Frando Frando added this pull request to the merge queue Aug 12, 2023
Merged via the queue into main with commit 1c3a3f1 Aug 12, 2023
@dignifiedquire dignifiedquire deleted the Frando/data-paths branch August 12, 2023 18:16
@b5 b5 added this to the v0.6.0 - Sync milestone Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants