Skip to content

Commit

Permalink
python: cleanup log discard
Browse files Browse the repository at this point in the history
Signed-off-by: RTann <[email protected]>
  • Loading branch information
RTann committed Jan 19, 2024
1 parent 0ae8f05 commit d372652
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/packagescanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ func findDeliciousEgg(ctx context.Context, sys fs.FS) (out []string, err error)
return out, fs.WalkDir(sys, ".", func(p string, d fs.DirEntry, err error) error {
ev := zlog.Debug(ctx).
Str("file", p)
var success bool
defer func() {
if !success {
ev.Discard().Send()
}
}()
switch {
case err != nil:
ev.Discard().Send()
return err
case (rpm || dpkg) && d.Type().IsDir():
// Skip one level up from the "packages" directory so the walk also
Expand All @@ -187,11 +192,9 @@ func findDeliciousEgg(ctx context.Context, sys fs.FS) (out []string, err error)
}
fallthrough
case !d.Type().IsRegular():
ev.Discard().Send()
// Should we chase symlinks with the correct name?
return nil
case strings.HasPrefix(filepath.Base(p), ".wh."):
ev.Discard().Send()
return nil
case strings.HasSuffix(p, `.egg/EGG-INFO/PKG-INFO`):
ev = ev.Str("kind", ".egg")
Expand All @@ -213,10 +216,10 @@ func findDeliciousEgg(ctx context.Context, sys fs.FS) (out []string, err error)
return nil
}
default:
ev.Discard().Send()
return nil
}
ev.Msg("found package")
success = true
out = append(out, p)
return nil
})
Expand Down

0 comments on commit d372652

Please sign in to comment.