Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

feat: path handling UX improvements #21

Merged
merged 3 commits into from
Jun 6, 2022
Merged

feat: path handling UX improvements #21

merged 3 commits into from
Jun 6, 2022

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Jun 2, 2022

A couple of things came up whilst implementing apache/datafusion#2677 that would make life easier.

  • Path::parse("/") would return an error
  • No easy way to convert a std::path::Path to object_store::path::Path for LocalFileSystem
  • Prefix match was private

This PR addresses these

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- I had some suggestions on docstrings but otherwise 👌

assert_eq!(Path::parse("/").unwrap().as_ref(), "");
assert_eq!(Path::parse("").unwrap().as_ref(), "");

let err = Path::parse("//").unwrap_err();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -214,6 +271,18 @@ where
}
}

pub(crate) fn filesystem_path_to_url(path: impl AsRef<std::path::Path>) -> Result<Url, Error> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a docstring explaining what this does would be useful as well

src/path/mod.rs Outdated
/// Convert a filesystem path to a [`Path`] relative to the provided base
///
/// This will return an error if the path does not exist, contains illegal
/// character sequences as defined by [`Path::parse`], or does not start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found "provided prefix" confusing as I didn't know what it was referring to. It seems to mean that the path must be prefixed by the the path in the base URL, if specified

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I renamed the parameters and forgot to update the docstring

@tustvold tustvold added the automerge Put in the merge queue label Jun 6, 2022
@kodiakhq kodiakhq bot merged commit 3997aa2 into main Jun 6, 2022
@tustvold tustvold mentioned this pull request Jun 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Put in the merge queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants