Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ rustc_version = "0.4"
serde = { version = "^1" }
serde_json = { version = "1" }
semver = "1.0"
shellexpand = "3.0"
slatedb = "0.3"
snafu = "0.8"
strum = "0.26"
Expand Down
14 changes: 2 additions & 12 deletions python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rust/lance-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ log.workspace = true
pin-project.workspace = true
prost.workspace = true
serde.workspace = true
shellexpand.workspace = true
snafu.workspace = true
tokio.workspace = true
tracing.workspace = true
Expand Down
23 changes: 19 additions & 4 deletions rust/lance-io/src/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use object_store::Error as ObjectStoreError;
use object_store::{path::Path, ObjectMeta, ObjectStore as OSObjectStore};
use providers::local::FileStoreProvider;
use providers::memory::MemoryStoreProvider;
use shellexpand::tilde;
use snafu::location;
use tokio::io::AsyncWriteExt;
use url::Url;
Expand Down Expand Up @@ -337,7 +336,8 @@ pub fn uri_to_url(uri: &str) -> Result<Url> {
}

fn expand_path(str_path: impl AsRef<str>) -> Result<std::path::PathBuf> {
let expanded = tilde(str_path.as_ref()).to_string();
let str_path = str_path.as_ref();
let expanded = expand_tilde_path(str_path).unwrap_or_else(|| str_path.into());

let mut expanded_path = path_abs::PathAbs::new(expanded)
.unwrap()
Expand All @@ -353,6 +353,22 @@ fn expand_path(str_path: impl AsRef<str>) -> Result<std::path::PathBuf> {
Ok(expanded_path)
}

fn expand_tilde_path(path: &str) -> Option<std::path::PathBuf> {
let home_dir = std::env::home_dir()?;
if path == "~" {
return Some(home_dir);
}
if let Some(stripped) = path.strip_prefix("~/") {
return Some(home_dir.join(stripped));
}
#[cfg(windows)]
if let Some(stripped) = path.strip_prefix("~\\") {
return Some(home_dir.join(stripped));
}

None
}

fn local_path_to_url(str_path: &str) -> Result<Url> {
let expanded_path = expand_path(str_path)?;

Expand Down Expand Up @@ -967,8 +983,7 @@ mod tests {

/// Write test content to file.
fn write_to_file(path_str: &str, contents: &str) -> std::io::Result<()> {
let expanded = tilde(path_str).to_string();
let path = StdPath::new(&expanded);
let path = expand_path(path_str).map_err(std::io::Error::other)?;
std::fs::create_dir_all(path.parent().unwrap())?;
write(path, contents)
}
Expand Down