diff --git a/src/clipboard/macos.rs b/src/clipboard/macos.rs index 6c653db..3777d21 100644 --- a/src/clipboard/macos.rs +++ b/src/clipboard/macos.rs @@ -56,18 +56,13 @@ impl super::ClipboardManager for MacClipboardManager { } fn set_clipboard_image(&self, image_path: &Path) { - // Make sure the image exist beforehand - if !image_path.exists() { - error!("Image not found in path: {:?}", image_path); - }else{ - let path_string = image_path.to_string_lossy().into_owned(); - let res = CString::new(path_string); - if let Ok(path) = res { - unsafe { - let result = set_clipboard_image(path.as_ptr()); - if result != 1 { - warn!("Couldn't set clipboard for image: {:?}", image_path) - } + let path_string = image_path.to_string_lossy().into_owned(); + let res = CString::new(path_string); + if let Ok(path) = res { + unsafe { + let result = set_clipboard_image(path.as_ptr()); + if result != 1 { + warn!("Couldn't set clipboard for image: {:?}", image_path) } } } diff --git a/src/engine.rs b/src/engine.rs index 5abdde0..d0163e6 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -219,8 +219,14 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa // Image Match MatchContentType::Image(content) => { let image_path = PathBuf::from(&content.path); - self.clipboard_manager.set_clipboard_image(&image_path); - self.keyboard_manager.trigger_paste(); + + // Make sure the image exist beforehand + if image_path.exists() { + self.clipboard_manager.set_clipboard_image(&image_path); + self.keyboard_manager.trigger_paste(); + }else{ + error!("Image not found in path: {:?}", image_path); + } }, } }