From e09d93a46873685a725c12ac8fd2b6a67807a8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Didrik=20Nordstr=C3=B6m?= Date: Fri, 3 Jan 2025 00:28:43 +0100 Subject: [PATCH] fix(opener): return error if path not exists --- .changes/fix-opener-open-path-error.md | 5 +++++ plugins/opener/src/open.rs | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 .changes/fix-opener-open-path-error.md diff --git a/.changes/fix-opener-open-path-error.md b/.changes/fix-opener-open-path-error.md new file mode 100644 index 00000000..8f8df55a --- /dev/null +++ b/.changes/fix-opener-open-path-error.md @@ -0,0 +1,5 @@ +--- +"opener": patch +"opener-js": patch +--- +`open_path` now returns an error if the file does not exist \ No newline at end of file diff --git a/plugins/opener/src/open.rs b/plugins/opener/src/open.rs index da531472..a3d46c50 100644 --- a/plugins/opener/src/open.rs +++ b/plugins/opener/src/open.rs @@ -53,5 +53,9 @@ pub fn open_url, S: AsRef>(url: P, with: Option) -> crate: /// ``` pub fn open_path, S: AsRef>(path: P, with: Option) -> crate::Result<()> { let path = path.as_ref(); + if with.is_none() { + // Returns an IO error if not exists, and besides `exists()` is a shorthand for `metadata()` + _ = path.metadata()?; + } open(path, with) }