Skip to content

Commit

Permalink
maybe not today
Browse files Browse the repository at this point in the history
Signed-off-by: Tarek <[email protected]>
  • Loading branch information
tareknaser committed Aug 6, 2024
1 parent 580902d commit 1dd3503
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 0 additions & 1 deletion fs-index/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ fn test_build_index_with_multiple_files() {
/// - Assert that the index contains two entries.
/// - Assert that the resources retrieved by path for each file match the
/// expected resources.
#[test]
fn test_build_index_with_multiple_directories() {
for_each_type!(Crc32, Blake3 => {
let temp_dir =
Expand Down
10 changes: 4 additions & 6 deletions fs-index/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,13 @@ pub(crate) fn discover_paths<P: AsRef<Path>>(
) -> Result<Vec<DirEntry>> {
log::debug!("Discovering paths at root path: {:?}", root_path.as_ref());

// Same but min_depth(1) to skip the root directory
for entry in WalkDir::new(&root_path).min_depth(1) {
// same but filter_entry(should_index) to skip hidden files
for entry in WalkDir::new(&root_path).min_depth(1).into_iter() {
let entry = entry.unwrap();
println!("WalkDir Entry (min_depth(1)): {:?}", entry.path());
// type
println!("\t\tFile type: {:?}", entry.file_type());
}

// same but filter_entry(should_index) to skip hidden files
for entry in WalkDir::new(&root_path).min_depth(1).into_iter() {
let entry = entry.unwrap();
// Ignore entries that don't pass the should_index filter
if !should_index(&entry) {
println!(
Expand Down Expand Up @@ -180,6 +176,7 @@ fn should_index(entry: &walkdir::DirEntry) -> bool {
.to_string_lossy()
.starts_with('.')
{
println!("\t\tFile is hidden");
return false;
}

Expand All @@ -189,6 +186,7 @@ fn should_index(entry: &walkdir::DirEntry) -> bool {
.map(|m| m.len() == 0)
.unwrap_or(false)
{
println!("\t\tFile is empty");
return false;
}

Expand Down

0 comments on commit 1dd3503

Please sign in to comment.