mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 11:36:36 +08:00
4e5797f1f4
- createPlaylistHandler: 200 → 201 Created, service errors → 500 - createSiteHandler: service/DB errors → 500 (was 400) - saveStorageConfigHandler: service errors → 500 (was 400) - SchedulerHandler.RunTask: task errors → 500 (was 400 with ErrInternal) - aria2StatsHandler: service errors → 500 (was 400) - organizeMediaHandler: service errors → 500 (was 400) - testDownloadClientHandler: test failure → 200 with ok:false (was 400) - testStorageConfigHandler: test failure → 200 with ok:false (was 400) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
33 lines
829 B
Go
33 lines
829 B
Go
// Package handler — media file organizer endpoints.
|
|
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/ShukeBta/MediaStationGo/internal/service"
|
|
)
|
|
|
|
func organizeMediaHandler(svc *service.Container) gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
dst, err := svc.Organizer.OrganizeMedia(c.Request.Context(), c.Param("id"))
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{"path": dst})
|
|
}
|
|
}
|
|
|
|
func organizeLibraryHandler(svc *service.Container) gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
res, err := svc.Organizer.OrganizeLibrary(c.Request.Context(), c.Param("id"))
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, res)
|
|
}
|
|
}
|