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.
This commit is contained in:
2026-03-06 10:48:36 -05:00
parent c5c7f50aac
commit 821cd3df4c
2 changed files with 4 additions and 12 deletions
+4 -9
View File
@@ -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
-3
View File
@@ -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{