Skip to content

Commit

Permalink
fix: allow reading from special files (device, fifo, etc) (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
theasp authored Sep 25, 2024
1 parent 4686c47 commit 16c5952
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/utils/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down

0 comments on commit 16c5952

Please sign in to comment.