From 0c5459f93b7605fea41230434e90660ace168101 Mon Sep 17 00:00:00 2001 From: Tarek Date: Tue, 6 Aug 2024 22:21:35 +0300 Subject: [PATCH] more resonable reasoning for a good reason Signed-off-by: Tarek --- .github/workflows/build.yml | 5 +---- fs-index/src/tests.rs | 1 - fs-index/src/utils.rs | 34 ++++++++++++++++++++-------------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 94591f1c..f55f6dbe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - debug-ci pull_request: branches: - main @@ -67,13 +68,9 @@ jobs: - name: Install Rust uses: dtolnay/rust-toolchain@stable - - name: Build Release - run: cargo build --verbose --release - - name: Run tests run: | cargo test --workspace --verbose - cargo test --workspace --verbose - name: Install JDK uses: actions/setup-java@v4.2.1 diff --git a/fs-index/src/tests.rs b/fs-index/src/tests.rs index 678042ed..509464b9 100644 --- a/fs-index/src/tests.rs +++ b/fs-index/src/tests.rs @@ -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 = diff --git a/fs-index/src/utils.rs b/fs-index/src/utils.rs index 745a196b..8e687146 100644 --- a/fs-index/src/utils.rs +++ b/fs-index/src/utils.rs @@ -78,21 +78,11 @@ pub(crate) fn discover_paths>( ) -> Result> { log::debug!("Discovering paths at root path: {:?}", root_path.as_ref()); - let walker = WalkDir::new(&root_path) - .min_depth(1) // Skip the root directory + let paths = WalkDir::new(root_path) + .min_depth(1) .into_iter() - .filter_entry(should_index); // Skip hidden files and empty files - - // Filter out directories - let paths = walker - .filter_map(|entry| { - let entry = entry.ok()?; - if entry.file_type().is_file() { - Some(entry) - } else { - None - } - }) + .filter_map(|e| e.ok()) + .filter(|e| should_index(e)) .collect(); Ok(paths) @@ -144,6 +134,7 @@ fn should_index(entry: &walkdir::DirEntry) -> bool { .to_string_lossy() .starts_with('.') { + println!("Hidden REJECTED: {:?}", entry.path()); return false; } @@ -153,8 +144,23 @@ fn should_index(entry: &walkdir::DirEntry) -> bool { .map(|m| m.len() == 0) .unwrap_or(false) { + println!("Empty REJECTED: {:?}", entry.path()); return false; } + // Check if the entry is a file + if !entry.file_type().is_file() { + println!("Not a file REJECTED: {:?}", entry.path()); + return false; + } + + // Check if it's 'root/index' file + if entry.path().ends_with(INDEX_PATH) { + println!("INDEX REJECTED: {:?}", entry.path()); + return false; + } + + println!("ACCEPTED: {:?}", entry.path()); + true }