From 52f17a3997e360e2607f2bd4179e464527a4a4b1 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Mon, 18 Dec 2023 20:32:07 +0100 Subject: [PATCH] fix(iroh): check output for blob get (#1898) Check we the result can be written to, before downloading. --- iroh/src/commands/blob.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/iroh/src/commands/blob.rs b/iroh/src/commands/blob.rs index a076220d8a..542bab0368 100644 --- a/iroh/src/commands/blob.rs +++ b/iroh/src/commands/blob.rs @@ -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}; @@ -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(),