Return None for unknown MIME types and ignore paste with warning
This commit is contained in:
parent
08d442aee2
commit
b8ac39ade5
2 changed files with 47 additions and 29 deletions
20
src/app.rs
20
src/app.rs
|
|
@ -3531,8 +3531,16 @@ impl Application for App {
|
|||
});
|
||||
}
|
||||
Message::PasteImageContents(to, contents) => {
|
||||
let Some(extension) = contents.extension() else {
|
||||
log::warn!(
|
||||
"Ignoring paste: unknown image MIME type {:?}",
|
||||
contents.mime_type
|
||||
);
|
||||
return Task::none();
|
||||
};
|
||||
|
||||
// Generate unique filename for the pasted image
|
||||
let base_name = format!("{}.{}", fl!("pasted-image"), contents.extension());
|
||||
let base_name = format!("{}.{}", fl!("pasted-image"), extension);
|
||||
let base_path = to.join(&base_name);
|
||||
let final_path = copy_unique_path(&base_path, &to);
|
||||
|
||||
|
|
@ -3558,8 +3566,16 @@ impl Application for App {
|
|||
});
|
||||
}
|
||||
Message::PasteVideoContents(to, contents) => {
|
||||
let Some(extension) = contents.extension() else {
|
||||
log::warn!(
|
||||
"Ignoring paste: unknown video MIME type {:?}",
|
||||
contents.mime_type
|
||||
);
|
||||
return Task::none();
|
||||
};
|
||||
|
||||
// Generate unique filename for the pasted video
|
||||
let base_name = format!("{}.{}", fl!("pasted-video"), contents.extension());
|
||||
let base_name = format!("{}.{}", fl!("pasted-video"), extension);
|
||||
let base_path = to.join(&base_name);
|
||||
let final_path = copy_unique_path(&base_path, &to);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue