Change Scanner interface signature
This commit is contained in:
parent
03957f2050
commit
fd8bc1ae9c
|
@ -87,7 +87,7 @@ func runNavidrome() {
|
|||
|
||||
func startServer(ctx context.Context) func() error {
|
||||
return func() error {
|
||||
a := CreateServer(conf.Server.MusicFolder)
|
||||
a := CreateServer()
|
||||
a.MountRouter("Native API", consts.URLPathNativeAPI, CreateNativeAPIRouter())
|
||||
a.MountRouter("Subsonic API", consts.URLPathSubsonicAPI, CreateSubsonicAPIRouter())
|
||||
a.MountRouter("Public Endpoints", consts.URLPathPublic, CreatePublicRouter())
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
// Injectors from wire_injectors.go:
|
||||
|
||||
func CreateServer(musicFolder string) *server.Server {
|
||||
func CreateServer() *server.Server {
|
||||
sqlDB := db.Db()
|
||||
dataStore := persistence.New(sqlDB)
|
||||
broker := events.GetBroker()
|
||||
|
|
|
@ -33,7 +33,7 @@ var allProviders = wire.NewSet(
|
|||
db.Db,
|
||||
)
|
||||
|
||||
func CreateServer(musicFolder string) *server.Server {
|
||||
func CreateServer() *server.Server {
|
||||
panic(wire.Build(
|
||||
server.New,
|
||||
allProviders,
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/core"
|
||||
"github.com/navidrome/navidrome/core/artwork"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
|
@ -15,11 +16,10 @@ import (
|
|||
|
||||
type Scanner interface {
|
||||
RescanAll(ctx context.Context, fullRescan bool) error
|
||||
Status(library string) (*StatusInfo, error)
|
||||
Status(context.Context) (*StatusInfo, error)
|
||||
}
|
||||
|
||||
type StatusInfo struct {
|
||||
Library string
|
||||
Scanning bool
|
||||
LastScan time.Time
|
||||
Count uint32
|
||||
|
@ -203,14 +203,13 @@ func (s *scanner) RescanAll(ctx context.Context, fullRescan bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *scanner) Status(library string) (*StatusInfo, error) {
|
||||
func (s *scanner) Status(context.Context) (*StatusInfo, error) {
|
||||
s.once.Do(s.loadFolders)
|
||||
status, ok := s.getStatus(library)
|
||||
status, ok := s.getStatus(conf.Server.MusicFolder)
|
||||
if !ok {
|
||||
return nil, errors.New("library not found")
|
||||
}
|
||||
return &StatusInfo{
|
||||
Library: library,
|
||||
Scanning: status.active,
|
||||
LastScan: status.lastUpdate,
|
||||
Count: status.fileCount,
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||
|
@ -12,10 +11,8 @@ import (
|
|||
)
|
||||
|
||||
func (api *Router) GetScanStatus(r *http.Request) (*responses.Subsonic, error) {
|
||||
// TODO handle multiple libraries
|
||||
ctx := r.Context()
|
||||
mediaFolder := conf.Server.MusicFolder
|
||||
status, err := api.scanner.Status(mediaFolder)
|
||||
status, err := api.scanner.Status(ctx)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving Scanner status", err)
|
||||
return nil, newError(responses.ErrorGeneric, "Internal Error")
|
||||
|
|
Loading…
Reference in New Issue