Skip to content

Commit

Permalink
fix: improve cleanup error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
pandres-varian committed May 13, 2024
1 parent 602dc3a commit 820dcf9
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions extension/storage/filestorage/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,26 +353,24 @@ func (c *fileStorageClient) cleanup(compactionDirectory string) error {
pattern := filepath.Join(compactionDirectory, fmt.Sprintf("%s*", tempDbPrefix))
contents, err := filepath.Glob(pattern)
if err != nil {
c.logger.Info("cleanup error listing temporary files",
zap.Error(err))
return err
}
delCont := 0
lockedCont := 0

var errs error
for _, item := range contents {
err = os.Remove(item)
if err == nil {
delCont++
c.logger.Debug("cleanup",
zap.String("deletedFile", item))
} else {
lockedCont++
c.logger.Debug("cleanup",
zap.String("lockedFile", item),
zap.Error(err))
errs = errors.Join(errs, err)
}

}
c.logger.Info("cleanup summary",
zap.Int("deletedFiles", delCont),
zap.Int("lockedFiles", lockedCont))
if errs != nil {
c.logger.Info("cleanup errors",
zap.Error(errs))
}
return nil
}

0 comments on commit 820dcf9

Please sign in to comment.