Skip to content

Commit

Permalink
fix(iroh): check output for blob get (#1898)
Browse files Browse the repository at this point in the history
Check we the result can be written to, before downloading.
  • Loading branch information
dignifiedquire committed Dec 18, 2023
1 parent f9776bb commit 52f17a3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion iroh/src/commands/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
time::Duration,
};

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{anyhow, bail, ensure, Context, Result};
use clap::Subcommand;
use console::{style, Emoji};
use futures::{Stream, StreamExt};
Expand Down Expand Up @@ -217,6 +217,14 @@ impl BlobCommands {
Some(OutputTarget::Stdout) => DownloadLocation::Internal,
Some(OutputTarget::Path(ref path)) => {
let absolute = std::env::current_dir()?.join(path);
match format {
BlobFormat::HashSeq => {
// no validation necessary for now
}
BlobFormat::Raw => {
ensure!(!absolute.is_dir(), "output must not be a directory");
}
}
tracing::info!(
"output path is {} -> {}",
path.display(),
Expand Down

0 comments on commit 52f17a3

Please sign in to comment.