Move image check in the engine

This commit is contained in:
Federico Terzi 2019-11-28 23:06:12 +01:00
parent 5c875eeaed
commit 283db379c8
2 changed files with 15 additions and 14 deletions

View File

@ -56,10 +56,6 @@ impl super::ClipboardManager for MacClipboardManager {
} }
fn set_clipboard_image(&self, image_path: &Path) { 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 path_string = image_path.to_string_lossy().into_owned();
let res = CString::new(path_string); let res = CString::new(path_string);
if let Ok(path) = res { if let Ok(path) = res {
@ -71,7 +67,6 @@ impl super::ClipboardManager for MacClipboardManager {
} }
} }
} }
}
} }
impl MacClipboardManager { impl MacClipboardManager {

View File

@ -219,8 +219,14 @@ impl <'a, S: KeyboardManager, C: ClipboardManager, M: ConfigManager<'a>, U: UIMa
// Image Match // Image Match
MatchContentType::Image(content) => { MatchContentType::Image(content) => {
let image_path = PathBuf::from(&content.path); let image_path = PathBuf::from(&content.path);
// Make sure the image exist beforehand
if image_path.exists() {
self.clipboard_manager.set_clipboard_image(&image_path); self.clipboard_manager.set_clipboard_image(&image_path);
self.keyboard_manager.trigger_paste(); self.keyboard_manager.trigger_paste();
}else{
error!("Image not found in path: {:?}", image_path);
}
}, },
} }
} }