Skip to content

Commit

Permalink
fix: use absolute paths everywhere (#836)
Browse files Browse the repository at this point in the history
Otherwise it is not possible to add things if the add cli has a different
$PATH than the daemon.
  • Loading branch information
rklaehn authored Mar 14, 2023
1 parent 7e5ac39 commit b2730ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,9 @@ async fn main_impl() -> Result<()> {
// task that will add data to the provider, either from a file or from stdin
let fut = tokio::spawn(async move {
let (path, tmp_path) = if let Some(path) = path {
println!("Adding {}...", path.display());
(path, None)
let absolute = path.canonicalize()?;
println!("Adding {} as {}...", path.display(), absolute.display());
(absolute, None)
} else {
// Store STDIN content into a temporary file
let (file, path) = tempfile::NamedTempFile::new()?.into_parts();
Expand Down Expand Up @@ -445,9 +446,10 @@ async fn main_impl() -> Result<()> {
}
Commands::Add { path, rpc_port } => {
let client = make_rpc_client(rpc_port).await?;
println!("Adding {}...", path.display());
let absolute = path.canonicalize()?;
println!("Adding {} as {}...", path.display(), absolute.display());
let ProvideResponse { hash, entries } =
client.rpc(ProvideRequest { path: path.clone() }).await??;
client.rpc(ProvideRequest { path: absolute }).await??;
print_add_response(hash, entries);
Ok(())
}
Expand Down

0 comments on commit b2730ee

Please sign in to comment.