Skip to content

Commit

Permalink
random bullshit go
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 05ab5a6 commit c47b7a5
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions fs-index/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ pub(crate) fn discover_paths<P: AsRef<Path>>(
println!("WalkDir Entry: {:?}", entry.path());
}

let walker = WalkDir::new(&root_path)
.min_depth(1) // Skip the root directory
.into_iter()
.filter_entry(should_index); // Skip hidden files and empty files
let walker = WalkDir::new(&root_path).into_iter();

// Filter out directories
let paths = walker
Expand All @@ -106,7 +103,7 @@ pub(crate) fn discover_paths<P: AsRef<Path>>(
println!("\t\tEntry: {:?}", entry.path());
// print entry type
println!("\t\t\tEntry Type: {:?}", entry.file_type());
if !entry.file_type().is_dir() {
if entry.file_type().is_file() {
Some(entry)
} else {
None
Expand Down Expand Up @@ -157,23 +154,23 @@ pub(crate) fn scan_entry<Id: ResourceId>(entry: DirEntry) -> Timestamped<Id> {
/// A helper function to check if the entry should be indexed (not hidden or
/// empty)
fn should_index(entry: &walkdir::DirEntry) -> bool {
// Check if the entry is hidden
if entry
.file_name()
.to_string_lossy()
.starts_with('.')
{
return false;
}

// Check if the entry is empty
if entry
.metadata()
.map(|m| m.len() == 0)
.unwrap_or(false)
{
return false;
}
// // Check if the entry is hidden
// if entry
// .file_name()
// .to_string_lossy()
// .starts_with('.')
// {
// return false;
// }

// // Check if the entry is empty
// if entry
// .metadata()
// .map(|m| m.len() == 0)
// .unwrap_or(false)
// {
// return false;
// }

true
}

0 comments on commit c47b7a5

Please sign in to comment.