I noticed that handlr incorrectly guesses some of the Qt Designer UI files' mime type, it should be application/x-designer, but handlr thinks it is application/x-gtk-builder.
$ handlr open SettingsWidgetFdoSecrets.ui
no handlers found for 'application/x-gtk-builder'
Directly using xdg-mime from xdg-utils returns the correct result:
From the code I see that the file name based guess is always preferred over a content-based guess.
However, according to the xdg_mime doc, the correct behavior is to first do a name-based guess, if the result has multiple matches, do a content-based guess and use the latter as the final result.
I tried a simple PoC and xdg_mime indeed returns the correct result in content guess.
use xdg_mime::SharedMimeInfo;
use std::path::PathBuf;
fn main() {
let path = PathBuf::from("SettingsWidgetFdoSecrets.ui");
let db = SharedMimeInfo::new();
let name_guesses = db.get_mime_types_from_file_name(&path.file_name().unwrap().to_string_lossy());
println!("name guesses: {:?}", name_guesses);
let content_guess = db.guess_mime_type().path(&path).guess();
println!("content guess: {:?}, uncertain {}", content_guess.mime_type(), content_guess.uncertain());
}
prints
name guesses: ["application/x-designer", "application/x-gtk-builder"]
content guess: "application/x-designer", uncertain false
I noticed that handlr incorrectly guesses some of the Qt Designer UI files' mime type, it should be
application/x-designer
, but handlr thinks it isapplication/x-gtk-builder
.Directly using
xdg-mime
fromxdg-utils
returns the correct result:From the code I see that the file name based guess is always preferred over a content-based guess.
However, according to the
xdg_mime
doc, the correct behavior is to first do a name-based guess, if the result has multiple matches, do a content-based guess and use the latter as the final result.I tried a simple PoC and xdg_mime indeed returns the correct result in content guess.
prints
The file used in the above examples: SettingsWidgetFdoSecrets.ui.zip