diff options
author | Kyohei Uto <kyoheiu@outlook.com> | 2022-10-22 05:47:07 +0900 |
---|---|---|
committer | Kyohei Uto <kyoheiu@outlook.com> | 2022-10-22 05:47:07 +0900 |
commit | 1b83c039f82e2f7d9302dc71adbc086a54ae4352 (patch) | |
tree | 71966091e4f67c5bd353a7d08c42ddec4d1f7954 /src/layout.rs | |
parent | 4bcecaa64228880193ba6b6997b5699718b736ae (diff) |
Add case where symlink points to text or binary
Diffstat (limited to 'src/layout.rs')
-rw-r--r-- | src/layout.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/layout.rs b/src/layout.rs index 495422c..0f15427 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -237,22 +237,25 @@ fn check_preview_type(item: &ItemInfo) -> PreviewType { if item.symlink_dir_path.is_some() { // assmuning symlink to be a directory PreviewType::Directory + } else if let Ok(content) = &std::fs::read(&item.file_path) { + if content_inspector::inspect(content).is_text() { + PreviewType::Text + } else { + PreviewType::Binary + } } else { PreviewType::UnresolvedSymlink } } else if is_supported_ext(item) { PreviewType::Image - } else { - if let Ok(content) = &std::fs::read(&item.file_path) { - let content_type = content_inspector::inspect(&content); - if content_type.is_text() { - PreviewType::Text - } else { - PreviewType::Binary - } + } else if let Ok(content) = &std::fs::read(&item.file_path) { + if content_inspector::inspect(content).is_text() { + PreviewType::Text } else { - PreviewType::NotReadable + PreviewType::Binary } + } else { + PreviewType::NotReadable } } |