Skip to content

Commit

Permalink
more resonable reasoning for a good reason
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 0e3cac8 commit 0c5459f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- debug-ci
pull_request:
branches:
- main
Expand Down Expand Up @@ -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/[email protected]
Expand Down
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
34 changes: 20 additions & 14 deletions fs-index/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,11 @@ pub(crate) fn discover_paths<P: AsRef<Path>>(
) -> Result<Vec<DirEntry>> {
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)
Expand Down Expand Up @@ -144,6 +134,7 @@ fn should_index(entry: &walkdir::DirEntry) -> bool {
.to_string_lossy()
.starts_with('.')
{
println!("Hidden REJECTED: {:?}", entry.path());
return false;
}

Expand All @@ -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
}

0 comments on commit 0c5459f

Please sign in to comment.