From 32f07971284f05993cf702aa589859e7900406b4 Mon Sep 17 00:00:00 2001 From: Jinho Bang Date: Wed, 17 Oct 2018 14:40:03 +0900 Subject: Fix a bug that copyFile reports different error codes This is a workaroud. Once the issue is resolved in Rust side, we should remove it. Fixes #895 --- src/ops.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/ops.rs b/src/ops.rs index 53ed85b7f..d786dfa41 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -811,6 +811,16 @@ fn op_copy_file( debug!("op_copy_file {} {}", from.display(), to.display()); blocking!(base.sync(), || { + // On *nix, Rust deem non-existent path as invalid input + // See https://github.com/rust-lang/rust/issues/54800 + // Once the issue is reolved, we should remove this workaround. + if cfg!(unix) && !from.is_file() { + return Err(errors::new( + ErrorKind::NotFound, + "File not found".to_string(), + )); + } + fs::copy(&from, &to)?; Ok(empty_buf()) }) -- cgit v1.2.3