try handle as file first

This commit is contained in:
yggverse 2025-02-13 10:11:21 +02:00
parent 0574ab81fd
commit 93da67aa7e

View File

@ -22,44 +22,42 @@ impl File {
prelude::FileExtManual, prelude::FileExtManual,
}; };
// try handle as directory // try handle as file
File::for_uri(&uri.to_string()).enumerate_children_async( File::for_uri(&uri.to_string()).load_contents_async(Some(&cancellable), {
"standard::content-type", let cancellable = cancellable.clone();
FileQueryInfoFlags::NONE, let uri = uri.clone();
Priority::DEFAULT, let _page = self.page.clone();
Some(&cancellable), move |result| match result {
{ Ok(_) => todo!(),
let cancellable = cancellable.clone(); // is not a file, try handle as directory
let uri = uri.clone(); Err(_) => File::for_uri(&uri.to_string()).enumerate_children_async(
let _page = self.page.clone(); "standard::content-type",
move |result| match result { FileQueryInfoFlags::NONE,
Ok(file_enumerator) => { Priority::DEFAULT,
for entry in file_enumerator { Some(&cancellable),
match entry { |result| match result {
Ok(file_info) => match file_info.file_type() { Ok(file_enumerator) => {
FileType::Unknown => todo!(), for entry in file_enumerator {
FileType::Regular => todo!(), match entry {
FileType::Directory => todo!(), Ok(file_info) => match file_info.file_type() {
FileType::SymbolicLink => todo!(), FileType::Unknown => todo!(),
FileType::Special => todo!(), FileType::Regular => todo!(),
FileType::Shortcut => todo!(), FileType::Directory => todo!(),
FileType::Mountable => todo!(), FileType::SymbolicLink => todo!(),
_ => todo!(), FileType::Special => todo!(),
}, FileType::Shortcut => todo!(),
Err(_) => todo!(), FileType::Mountable => todo!(),
_ => todo!(),
},
Err(_) => todo!(),
}
} }
} }
}
// is not a directory, try handle as file Err(_) => todo!(),
Err(_) => File::for_uri(&uri.to_string()).load_contents_async( },
Some(&cancellable), ),
|result| match result { }
Ok(_) => todo!(), });
Err(_) => todo!(),
},
),
}
},
)
} }
} }