summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Phillips <theasp@users.noreply.github.com>2024-09-25 10:55:55 -0300
committerGitHub <noreply@github.com>2024-09-25 21:55:55 +0800
commit16c5952ee4b861460381f0e387f7e86352036fae (patch)
tree71d9785a4564537e4e8ee8393cd1712cc6fd8323 /src
parent4686c476e99d1448daab25b189bdac4cd851b7fe (diff)
downloadaichat-16c5952ee4b861460381f0e387f7e86352036fae.tar.gz
fix: allow reading from special files (device, fifo, etc) (#886)
Diffstat (limited to 'src')
-rw-r--r--src/utils/path.rs25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/utils/path.rs b/src/utils/path.rs
index 83e51c7..e27b5ee 100644
--- a/src/utils/path.rs
+++ b/src/utils/path.rs
@@ -84,21 +84,18 @@ async fn list_files(
if !entry_path.exists() {
bail!("Not found: {}", entry_path.display());
}
- if entry_path.is_file() {
- add_file(files, suffixes, entry_path);
- return Ok(());
- }
- if !entry_path.is_dir() {
- bail!("Not a directory: {:?}", entry_path);
- }
- let mut reader = tokio::fs::read_dir(entry_path).await?;
- while let Some(entry) = reader.next_entry().await? {
- let path = entry.path();
- if path.is_file() {
- add_file(files, suffixes, &path);
- } else if path.is_dir() {
- list_files(files, &path, suffixes).await?;
+ if entry_path.is_dir() {
+ let mut reader = tokio::fs::read_dir(entry_path).await?;
+ while let Some(entry) = reader.next_entry().await? {
+ let path = entry.path();
+ if path.is_dir() {
+ list_files(files, &path, suffixes).await?;
+ } else {
+ add_file(files, suffixes, &path);
+ }
}
+ } else {
+ add_file(files, suffixes, entry_path);
}
Ok(())
}