From 821cd3df4c74c1d8ff160d07e9105335d3cea10a Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 6 Mar 2026 10:48:36 -0500 Subject: [PATCH] refactor(services): remove debug logging and fix directory scanning - Remove debug printf statements from media scanner and worker - Remove unused debug tracking variables (filesSeen, filesProcessed) - Fix directory walk logic to properly scan the root directory itself (previous implementation would skip the root path entirely) Clean up production code by removing debug artifacts and improving the directory scanning logic to handle root-level directories correctly. --- internal/services/media_scanner.go | 13 ++++--------- internal/services/worker.go | 3 --- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/internal/services/media_scanner.go b/internal/services/media_scanner.go index dcf3ad8..65a32a6 100644 --- a/internal/services/media_scanner.go +++ b/internal/services/media_scanner.go @@ -1871,9 +1871,6 @@ func (s *MediaScanner) waitForFileStability(filePath string) bool { } func (s *MediaScanner) scanDirectory(ctx context.Context, dirPath string) { - // Debug: Track file processing - filesSeen := 0 - filesProcessed := 0 // Prevent concurrent scans of ANY directory // Simple mutex is enough - job queue already serializes by directory s.scan_mutex.Lock() @@ -1904,7 +1901,10 @@ func (s *MediaScanner) scanDirectory(ctx context.Context, dirPath string) { return err } if d.IsDir() { - return filepath.SkipDir + if path != dirPath { + return filepath.SkipDir + } + return nil } if !s.isScannableFile(path) { return nil @@ -1914,7 +1914,6 @@ func (s *MediaScanner) scanDirectory(ctx context.Context, dirPath string) { if !s.waitForFileStability(path) { return nil } - filesSeen++ relPath := strings.TrimPrefix(path, rootFolder+"/") _, err = s.db.GetMediaItemByFilePath(ctx, database.GetMediaItemByFilePathParams{ FilePath: relPath, @@ -1928,14 +1927,10 @@ func (s *MediaScanner) scanDirectory(ctx context.Context, dirPath string) { s.newItems++ } s.totalFiles++ - filesProcessed++ } return nil }) - // Debug: Report scan results - fmt.Printf("DEBUG: scanDirectory of %s - filesSeen: %d, filesProcessed: %d, totalFiles: %d, newItems: %d, errors: %d\n", - dirPath, filesSeen, filesProcessed, s.totalFiles, s.newItems, s.errors) } // performInitialScan scans all root folders on startup diff --git a/internal/services/worker.go b/internal/services/worker.go index c7dd2b1..5346648 100644 --- a/internal/services/worker.go +++ b/internal/services/worker.go @@ -910,9 +910,6 @@ func (w *Worker) processDirectoryScanJob(job *Job) (interface{}, error) { } // Now scan the directory scanner.scanDirectory(ctx, directory) - // Debug logging - fmt.Printf("DEBUG: scanDirectory completed - totalFiles: %d, newItems: %d, errors: %d\n", - scanner.totalFiles, scanner.newItems, scanner.errors) // Return scan results return &DirectoryScanJobResult{