From 820dcf9f98c0a6de46d42ec8631b88ff9910077f Mon Sep 17 00:00:00 2001 From: Pedro Andres Blanco Date: Mon, 13 May 2024 10:31:37 +0200 Subject: [PATCH] fix: improve cleanup error logging --- extension/storage/filestorage/client.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/extension/storage/filestorage/client.go b/extension/storage/filestorage/client.go index 752f99b876a7..18a54c2f4bd8 100644 --- a/extension/storage/filestorage/client.go +++ b/extension/storage/filestorage/client.go @@ -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 }