[+] Add has_thumb return

This commit is contained in:
Azalea Gui
2023-02-23 15:23:03 -05:00
parent 79292e89f2
commit df70bc2e28
+4 -1
View File
@@ -54,6 +54,7 @@ pub struct ReturnPath {
mtime: i64,
size: u64,
mime: Option<String>,
has_thumb: bool
}
struct MyApp {
@@ -83,12 +84,14 @@ impl MyApp {
.filter_map(|x| x.ok())
.filter_map(|x| {
let m = x.metadata().ok()?;
let mime = if x.path().is_file() { self.generator.get_mime(&x.path()).ok() } else { None };
Some(ReturnPath {
name: x.file_name().to_str()?.to_string(),
file_type: x.path().file_type().to_string(),
mtime: m.mtime() * 1000,
size: m.len(),
mime: if x.path().is_file() { self.generator.get_mime(&x.path()).ok() } else { None }
mime: mime.to_owned(),
has_thumb: mime.is_some() && self.generator.thumbnailers.find(&*mime.unwrap()).is_some()
})
}).collect();