Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Walker updates & better tests #6

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cleanup walking.
thushan committed Nov 9, 2023

Verified

This commit was signed with the committer’s verified signature.
thushan Thushan Fernando
commit 7329383fa7490f18d5b2a9f4a4927a1ac1c74a1f
11 changes: 5 additions & 6 deletions pkg/indexer/indexer.go
Original file line number Diff line number Diff line change
@@ -53,19 +53,19 @@ func (config *IndexerConfig) WalkDirectory(f fs.FS, root string, files chan File
if err != nil {
return err
}
name := filepath.Clean(d.Name())
if d.IsDir() {
if config.isSystemFolder(d.Name()) || (len(config.ExcludeDirFilter) > 0 && config.dirMatcher.MatchString(path)) {
if config.isSystemFolder(name) || (len(config.ExcludeDirFilter) > 0 && config.dirMatcher.MatchString(path)) {
return filepath.SkipDir
}
} else {
filename := filepath.Base(path)
if len(config.ExcludeFileFilter) > 0 && config.fileMatcher.MatchString(filename) {
if len(config.ExcludeFileFilter) > 0 && config.fileMatcher.MatchString(name) {
return nil
}
files <- FileFS{
FileSystem: f,
Path: path,
Name: filename,
Name: name,
FullName: filepath.Join(root, path),
}
}
@@ -74,8 +74,7 @@ func (config *IndexerConfig) WalkDirectory(f fs.FS, root string, files chan File
return walkErr
}

func (config *IndexerConfig) isSystemFolder(path string) bool {
folder := filepath.Clean(path)
func (config *IndexerConfig) isSystemFolder(folder string) bool {
for _, v := range config.excludeSysFilter {
if folder == v {
return true