From df70bc2e2820920bef0bf6621f386fcd50138f69 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 23 Feb 2023 15:23:03 -0500 Subject: [PATCH] [+] Add has_thumb return --- backend/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/main.rs b/backend/src/main.rs index b0176d4..e47ec4c 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -54,6 +54,7 @@ pub struct ReturnPath { mtime: i64, size: u64, mime: Option, + 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();