Skip to content

Commit f042d0b

Browse files
authored
fix(internal/librarian): change log level to debug (#2798)
The directory removal is expected to fail if the directory is not empty. Change the log level to debug so we know why the directory is not removed in debug mode. Fixes #2687
1 parent be56755 commit f042d0b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

internal/librarian/command.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,10 @@ func clean(rootDir string, sourceRoots, removePatterns, preservePatterns []strin
568568
var relPaths []string
569569
for _, sourceRoot := range sourceRoots {
570570
sourceRootPath := filepath.Join(rootDir, sourceRoot)
571-
// If a source root does not exist, log a warning and searching the other source roots.
572-
// TODO: Consider not calling clean if it's a first time generation
573571
if _, err := os.Lstat(sourceRootPath); err != nil {
574572
if os.IsNotExist(err) {
575-
slog.Warn("unable to find source root. It may be an initial generation request", "source root", sourceRoot)
573+
// If a source root does not exist, continue searching other source roots.
574+
slog.Debug("unable to find source root. It may be an initial generation request", "source root", sourceRoot)
576575
continue
577576
}
578577
// For any other error (permissions, I/O, etc.)
@@ -581,9 +580,8 @@ func clean(rootDir string, sourceRoots, removePatterns, preservePatterns []strin
581580
}
582581
sourceRootPaths, err := findSubDirRelPaths(rootDir, sourceRootPath)
583582
if err != nil {
584-
// Log a warning and continue processing other source roots. There may be other files
585-
// that can be cleaned up.
586-
slog.Warn("unable to search for files in a source root", "source root", sourceRoot, "error", err)
583+
// Continue processing other source roots. There may be other files that can be cleaned up.
584+
slog.Debug("unable to search for files in a source root", "source root", sourceRoot, "error", err)
587585
continue
588586
}
589587
if len(sourceRootPaths) == 0 {
@@ -630,7 +628,7 @@ func clean(rootDir string, sourceRoots, removePatterns, preservePatterns []strin
630628
slog.Debug("removing directory", "path", dir)
631629
if err := os.Remove(dir); err != nil {
632630
// It's possible the directory is not empty due to preserved files.
633-
slog.Warn("failed to remove directory, it may not be empty", "dir", dir, "err", err)
631+
slog.Debug("failed to remove directory, it may not be empty due to preserved files", "dir", dir, "err", err)
634632
}
635633
}
636634

0 commit comments

Comments
 (0)