mirror of
https://github.com/sxyazi/yazi.git
synced 2024-11-24 09:53:12 +03:00
fix: unknown mime-type of inode/x-empty
(#36)
This commit is contained in:
parent
d9624cf42f
commit
e123137823
@ -59,6 +59,7 @@ impl Preview {
|
|||||||
|
|
||||||
self.handle = Some(tokio::spawn(async move {
|
self.handle = Some(tokio::spawn(async move {
|
||||||
let result = match kind {
|
let result = match kind {
|
||||||
|
MimeKind::Empty => Ok(PreviewData::None),
|
||||||
MimeKind::Archive => Self::archive(&path).await.map(PreviewData::Text),
|
MimeKind::Archive => Self::archive(&path).await.map(PreviewData::Text),
|
||||||
MimeKind::Dir => Self::folder(&path).await,
|
MimeKind::Dir => Self::folder(&path).await,
|
||||||
MimeKind::Image => Self::image(&path).await,
|
MimeKind::Image => Self::image(&path).await,
|
||||||
|
@ -2,6 +2,8 @@ pub const MIME_DIR: &str = "inode/directory";
|
|||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum MimeKind {
|
pub enum MimeKind {
|
||||||
|
Empty,
|
||||||
|
|
||||||
Archive,
|
Archive,
|
||||||
Dir,
|
Dir,
|
||||||
|
|
||||||
@ -17,6 +19,10 @@ pub enum MimeKind {
|
|||||||
|
|
||||||
impl MimeKind {
|
impl MimeKind {
|
||||||
pub fn valid(s: &str) -> bool {
|
pub fn valid(s: &str) -> bool {
|
||||||
|
if s == "inode/x-empty" {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
let parts = s.split('/').collect::<Vec<_>>();
|
let parts = s.split('/').collect::<Vec<_>>();
|
||||||
if parts.len() != 2 {
|
if parts.len() != 2 {
|
||||||
return false;
|
return false;
|
||||||
@ -47,6 +53,8 @@ impl MimeKind {
|
|||||||
Self::Image
|
Self::Image
|
||||||
} else if s.starts_with("video/") {
|
} else if s.starts_with("video/") {
|
||||||
Self::Video
|
Self::Video
|
||||||
|
} else if s == "inode/x-empty" {
|
||||||
|
Self::Empty
|
||||||
} else if s == "application/json" {
|
} else if s == "application/json" {
|
||||||
Self::JSON
|
Self::JSON
|
||||||
} else if s == "application/pdf" {
|
} else if s == "application/pdf" {
|
||||||
|
Loading…
Reference in New Issue
Block a user