fix: record last error when calling processDir
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
鲁树人 2024-10-08 22:01:36 +01:00
parent 2afc232eb1
commit 1091eebf4b

View File

@ -143,6 +143,7 @@ func appMain(c *cli.Context) (err error) {
} }
proc := &processor{ proc := &processor{
errorCount: 0,
outputDir: output, outputDir: output,
skipNoopDecoder: c.Bool("skip-noop"), skipNoopDecoder: c.Bool("skip-noop"),
removeSource: c.Bool("remove-source"), removeSource: c.Bool("remove-source"),
@ -170,6 +171,7 @@ type processor struct {
removeSource bool removeSource bool
updateMetadata bool updateMetadata bool
overwriteOutput bool overwriteOutput bool
errorCount int
} }
func (p *processor) watchDir(inputDir string) error { func (p *processor) watchDir(inputDir string) error {
@ -231,6 +233,8 @@ func (p *processor) processDir(inputDir string) error {
if err != nil { if err != nil {
return err return err
} }
var lastError error = nil
for _, item := range items { for _, item := range items {
if item.IsDir() { if item.IsDir() {
continue continue
@ -238,10 +242,11 @@ func (p *processor) processDir(inputDir string) error {
filePath := filepath.Join(inputDir, item.Name()) filePath := filepath.Join(inputDir, item.Name())
if err := p.processFile(filePath); err != nil { if err := p.processFile(filePath); err != nil {
lastError = err
logger.Error("conversion failed", zap.String("source", item.Name()), zap.Error(err)) logger.Error("conversion failed", zap.String("source", item.Name()), zap.Error(err))
} }
} }
return nil return lastError
} }
func (p *processor) processFile(filePath string) error { func (p *processor) processFile(filePath string) error {