fix(media): scan new library roots immediately

This commit is contained in:
ShukeBta
2026-08-10 19:15:58 +08:00
parent a64a98be23
commit 60d2cfe2f1
4 changed files with 100 additions and 5 deletions
+15 -3
View File
@@ -32,7 +32,12 @@ func createLibraryRootHandler(svc *service.Container) gin.HandlerFunc {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
go func() { _ = svc.Watcher.Refresh(context.Background()) }()
if svc.Watcher != nil {
go func() { _ = svc.Watcher.Refresh(context.Background()) }()
}
if root.Enabled {
queueLibraryRootScan(svc, c.Param("id"), root.ID)
}
c.JSON(http.StatusCreated, root)
}
}
@@ -53,7 +58,12 @@ func updateLibraryRootHandler(svc *service.Container) gin.HandlerFunc {
c.JSON(http.StatusNotFound, gin.H{"error": "library root not found"})
return
}
go func() { _ = svc.Watcher.Refresh(context.Background()) }()
if svc.Watcher != nil {
go func() { _ = svc.Watcher.Refresh(context.Background()) }()
}
if root.Enabled {
queueLibraryRootScan(svc, c.Param("id"), root.ID)
}
c.JSON(http.StatusOK, root)
}
}
@@ -64,7 +74,9 @@ func deleteLibraryRootHandler(svc *service.Container) gin.HandlerFunc {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
go func() { _ = svc.Watcher.Refresh(context.Background()) }()
if svc.Watcher != nil {
go func() { _ = svc.Watcher.Refresh(context.Background()) }()
}
c.Status(http.StatusNoContent)
}
}