Only scan regular files (#87)

* Only scan regular files

* Remove IsDirectory func
This commit is contained in:
Bill Rich 2022-03-16 15:04:10 -08:00 committed by GitHub
parent deabded54b
commit 5ab5c6f9d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,15 +77,6 @@ func (s *Source) Init(aCtx context.Context, name string, jobId, sourceId int64,
return nil
}
func isDirectory(path string) (bool, error) {
fileInfo, err := os.Stat(path)
if err != nil {
return false, err
}
return fileInfo.IsDir(), err
}
// Chunks emits chunks of bytes over a channel.
func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) error {
for i, path := range s.paths {
@ -105,7 +96,8 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk) err
path := filepath.Join(cleanPath, relativePath)
if ok, _ := isDirectory(path); ok {
fileStat, _ := os.Stat(path)
if !fileStat.Mode().IsRegular() {
return nil
}