fix: don't read files if list empty
This commit is contained in:
parent
0b7294d4e4
commit
75fe043e73
2 changed files with 13 additions and 4 deletions
|
|
@ -3840,10 +3840,10 @@ impl Application for App {
|
|||
// Check if clipboard has any paste-able content and cache it
|
||||
return clipboard::read_data::<ClipboardPaste>().map(|contents_opt| {
|
||||
match contents_opt {
|
||||
Some(contents) => cosmic::action::app(Message::ClipboardCached(
|
||||
ClipboardCache::Files(contents),
|
||||
)),
|
||||
None => cosmic::action::app(Message::CheckClipboardImage),
|
||||
Some(contents) if !contents.paths.is_empty() => cosmic::action::app(
|
||||
Message::ClipboardCached(ClipboardCache::Files(contents)),
|
||||
),
|
||||
_ => cosmic::action::app(Message::CheckClipboardImage),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,9 +128,14 @@ impl TryFrom<(Vec<u8>, String)> for ClipboardPaste {
|
|||
// Assume the kind is Copy if not provided by the mime type
|
||||
let mut kind = ClipboardKind::Copy;
|
||||
let mut paths = Vec::new();
|
||||
|
||||
match mime.as_str() {
|
||||
"text/uri-list" => {
|
||||
let text = str::from_utf8(&data)?;
|
||||
let lines = text.lines();
|
||||
if text.is_empty() || lines.count() == 0 {
|
||||
Err(format!("Empty file url"))?;
|
||||
}
|
||||
for line in text.lines() {
|
||||
let url = Url::parse(line)?;
|
||||
match url.to_file_path() {
|
||||
|
|
@ -141,6 +146,10 @@ impl TryFrom<(Vec<u8>, String)> for ClipboardPaste {
|
|||
}
|
||||
"x-special/gnome-copied-files" => {
|
||||
let text = str::from_utf8(&data)?;
|
||||
let lines = text.lines();
|
||||
if text.is_empty() || lines.count() == 0 {
|
||||
Err(format!("Empty file url"))?;
|
||||
}
|
||||
for (i, line) in text.lines().enumerate() {
|
||||
if i == 0 {
|
||||
kind = match line {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue