Add folder validation to CreateMediaItem handler

- Check library has folders before creating media items
- Return HTTP 400 with clear error message if no folders
- Proper error code (400) instead of generic 500
- Improved user feedback for invalid operations
- Inject LibraryService into MediaHandler

Fixes: TestCollectionsBulkOperations HTTP 500 errors
Related: Service layer validation commit
This commit is contained in:
2026-02-09 14:28:58 -05:00
parent cd20c8e96d
commit 6b1815de12
2 changed files with 21 additions and 5 deletions
+4 -1
View File
@@ -92,6 +92,9 @@ func main() {
// Create sync queue processor
queueProcessor := sync.NewSyncQueueProcessor(queries)
// Create library service
libraryService := services.NewLibraryService(queries)
// Create worker for background tasks
worker := services.NewWorker(3)
@@ -107,7 +110,7 @@ func main() {
// NEW: Create refactored handlers
collectionHandler := handlers.NewCollectionHandler(queries, connManager)
mediaHandler := handlers.NewMediaHandler(queries, worker)
mediaHandler := handlers.NewMediaHandler(queries, libraryService, worker)
searchHandler := handlers.NewSearchHandler(queries)
matchingHandler := handlers.NewMatchingHandler(queries, connManager)