From e123137823aeedee56f39c720094d3c22bcdb8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Tue, 8 Aug 2023 15:47:27 +0800 Subject: [PATCH] fix: unknown mime-type of `inode/x-empty` (#36) --- core/src/manager/preview.rs | 1 + shared/src/mime.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/core/src/manager/preview.rs b/core/src/manager/preview.rs index 65adce72..db303eb9 100644 --- a/core/src/manager/preview.rs +++ b/core/src/manager/preview.rs @@ -59,6 +59,7 @@ impl Preview { self.handle = Some(tokio::spawn(async move { let result = match kind { + MimeKind::Empty => Ok(PreviewData::None), MimeKind::Archive => Self::archive(&path).await.map(PreviewData::Text), MimeKind::Dir => Self::folder(&path).await, MimeKind::Image => Self::image(&path).await, diff --git a/shared/src/mime.rs b/shared/src/mime.rs index be0af996..a59df274 100644 --- a/shared/src/mime.rs +++ b/shared/src/mime.rs @@ -2,6 +2,8 @@ pub const MIME_DIR: &str = "inode/directory"; #[derive(Clone, Copy, PartialEq, Eq)] pub enum MimeKind { + Empty, + Archive, Dir, @@ -17,6 +19,10 @@ pub enum MimeKind { impl MimeKind { pub fn valid(s: &str) -> bool { + if s == "inode/x-empty" { + return true; + } + let parts = s.split('/').collect::>(); if parts.len() != 2 { return false; @@ -47,6 +53,8 @@ impl MimeKind { Self::Image } else if s.starts_with("video/") { Self::Video + } else if s == "inode/x-empty" { + Self::Empty } else if s == "application/json" { Self::JSON } else if s == "application/pdf" {