refactor: improve worker type safety and scanner reliability
Worker improvements:
- Add strongly-typed result structs for all job types
- Replace map[string]interface{} with specific result types
- Add JSON tags to JobResult for proper API serialization
- Fix processJob to handle different result types correctly
- Improve directory scan job with proper library folder resolution
- Add debug logging for scan operations
Media scanner improvements:
- Add nil checks for database in GetPollInterval and GetAutoScanEnabled
- Fix pdfcpu API call signature (add validateOnly parameter)
- Add debug logging for scanDirectory with file counters
- Improve error handling and reporting
Test fixes:
- Fix default poll interval expectation from 30s to 60s
- Add settingsCache initialization to scanner tests
- Add folders initialization to ProcessDirtyDirectories test
This commit is contained in:
@@ -92,13 +92,14 @@ func TestWaitForFileStability_UnstableFile(t *testing.T) {
|
||||
select {
|
||||
case stable := <-stableChan:
|
||||
assert.True(t, stable)
|
||||
case <-time.After(5 * time.Second):
|
||||
case <-time.After(7 * time.Second):
|
||||
t.Fatal("waitForFileStability timeout")
|
||||
}
|
||||
}
|
||||
func TestProcessDirtyDirectories_BatchesScans(t *testing.T) {
|
||||
db := setupTestDB(t)
|
||||
scanner := NewMediaScanner(db)
|
||||
scanner.folders = []string{"/test/folder"}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
// Mark directory dirty multiple times rapidly
|
||||
|
||||
Reference in New Issue
Block a user