Skip to content

Commit ea5fc39

Browse files
authored
Change filesystem unit enumeration to use provided inputs (#4163)
Instead of recursively finding all files and emitting them as units, this will simply pass the configured paths as units to the source. Directories will get recursively chunked when scanned.
1 parent a6a4aed commit ea5fc39

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

pkg/sources/filesystem/filesystem.go

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -201,38 +201,16 @@ func (s *Source) scanFile(ctx context.Context, path string, chunksChan chan *sou
201201
// filepath or a directory.
202202
func (s *Source) Enumerate(ctx context.Context, reporter sources.UnitReporter) error {
203203
for _, path := range s.paths {
204-
fileInfo, err := os.Lstat(filepath.Clean(path))
204+
_, err := os.Lstat(filepath.Clean(path))
205205
if err != nil {
206206
if err := reporter.UnitErr(ctx, err); err != nil {
207207
return err
208208
}
209209
continue
210210
}
211-
if !fileInfo.IsDir() {
212-
item := sources.CommonSourceUnit{ID: path}
213-
if err := reporter.UnitOk(ctx, item); err != nil {
214-
return err
215-
}
216-
continue
217-
}
218-
err = fs.WalkDir(os.DirFS(path), ".", func(relativePath string, d fs.DirEntry, err error) error {
219-
if err != nil {
220-
return reporter.UnitErr(ctx, err)
221-
}
222-
if d.IsDir() {
223-
return nil
224-
}
225-
fullPath := filepath.Join(path, relativePath)
226-
if s.filter != nil && !s.filter.Pass(fullPath) {
227-
return nil
228-
}
229-
item := sources.CommonSourceUnit{ID: fullPath}
230-
return reporter.UnitOk(ctx, item)
231-
})
232-
if err != nil {
233-
if err := reporter.UnitErr(ctx, err); err != nil {
234-
return err
235-
}
211+
item := sources.CommonSourceUnit{ID: path}
212+
if err := reporter.UnitOk(ctx, item); err != nil {
213+
return err
236214
}
237215
}
238216
return nil

0 commit comments

Comments
 (0)