@@ -109,7 +109,9 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ .
109
109
}
110
110
111
111
if err != nil && ! errors .Is (err , io .EOF ) {
112
- logger .Info ("error scanning filesystem" , "error" , err )
112
+ if ! errors .Is (err , skipSymlinkErr ) {
113
+ logger .Error (err , "error scanning filesystem" )
114
+ }
113
115
}
114
116
}
115
117
@@ -148,14 +150,16 @@ func (s *Source) scanDir(ctx context.Context, path string, chunksChan chan *sour
148
150
})
149
151
}
150
152
153
+ var skipSymlinkErr = errors .New ("skipping symlink" )
154
+
151
155
func (s * Source ) scanFile (ctx context.Context , path string , chunksChan chan * sources.Chunk ) error {
152
156
logger := ctx .Logger ().WithValues ("path" , path )
153
157
fileStat , err := os .Lstat (path )
154
158
if err != nil {
155
159
return fmt .Errorf ("unable to stat file: %w" , err )
156
160
}
157
161
if fileStat .Mode ()& os .ModeSymlink != 0 {
158
- return fmt . Errorf ( "skipping symlink" )
162
+ return skipSymlinkErr
159
163
}
160
164
161
165
inputFile , err := os .Open (path )
@@ -259,8 +263,10 @@ func (s *Source) ChunkUnit(ctx context.Context, unit sources.SourceUnit, reporte
259
263
}
260
264
}
261
265
262
- if scanErr != nil && scanErr != io .EOF {
263
- logger .Info ("error scanning filesystem" , "error" , scanErr )
266
+ if scanErr != nil && ! errors .Is (scanErr , io .EOF ) {
267
+ if ! errors .Is (scanErr , skipSymlinkErr ) {
268
+ logger .Error (scanErr , "error scanning filesystem" )
269
+ }
264
270
return reporter .ChunkErr (ctx , scanErr )
265
271
}
266
272
return nil
0 commit comments