From 8c1deed6b8cd87a2de04bf92c5cd997c3ccd322b Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 22 Mar 2026 21:23:35 +0800 Subject: Handle missing file by returning empty sheet data --- src/cmds/cmd/sheetedit.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cmds/cmd/sheetedit.rs b/src/cmds/cmd/sheetedit.rs index 85cb616..8e3449e 100644 --- a/src/cmds/cmd/sheetedit.rs +++ b/src/cmds/cmd/sheetedit.rs @@ -59,9 +59,13 @@ async fn collect(args: &Arg, ctx: &JVCommandContext) -> Result tokio::fs::read(stdin_path) .await .map_err(CmdPrepareError::Io)?, - (Some(file_path), None) => tokio::fs::read(file_path) - .await - .map_err(CmdPrepareError::Io)?, + (Some(file_path), None) => match tokio::fs::read(file_path).await { + Ok(data) => data, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => { + SheetData::empty().as_bytes().to_vec() + } + Err(e) => return Err(CmdPrepareError::Io(e)), + }, (None, None) => return early_cmd_output!(JVNoneOutput => JVNoneOutput), }; Ok(Collect { data }) -- cgit