Associate main entities with library
This commit is contained in:
+3
-11
@@ -15,12 +15,13 @@ import (
|
||||
)
|
||||
|
||||
func initialSetup(ds model.DataStore) {
|
||||
ctx := context.TODO()
|
||||
_ = ds.WithTx(func(tx model.DataStore) error {
|
||||
if err := createOrUpdateMusicFolder(ds); err != nil {
|
||||
if err := ds.Library(ctx).StoreMusicFolder(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
properties := ds.Property(context.TODO())
|
||||
properties := ds.Property(ctx)
|
||||
_, err := properties.Get(consts.InitialSetupFlagKey)
|
||||
if err == nil {
|
||||
return nil
|
||||
@@ -116,12 +117,3 @@ func checkExternalCredentials() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func createOrUpdateMusicFolder(ds model.DataStore) error {
|
||||
lib := model.Library{ID: 1, Name: "Music Library", Path: conf.Server.MusicFolder}
|
||||
err := ds.Library(context.TODO()).Put(&lib)
|
||||
if err != nil {
|
||||
log.Error("Could not access Library table", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/navidrome/navidrome/conf"
|
||||
@@ -30,22 +29,14 @@ func (api *Router) GetMusicFolders(r *http.Request) (*responses.Subsonic, error)
|
||||
|
||||
func (api *Router) getArtistIndex(r *http.Request, libId int, ifModifiedSince time.Time) (*responses.Indexes, error) {
|
||||
ctx := r.Context()
|
||||
folder, err := api.ds.Library(ctx).Get(libId)
|
||||
lib, err := api.ds.Library(ctx).Get(libId)
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving Library", "id", libId, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
l, err := api.ds.Property(ctx).DefaultGet(model.PropLastScan+"-"+folder.Path, "-1")
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving LastScan property", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var indexes model.ArtistIndexes
|
||||
ms, _ := strconv.ParseInt(l, 10, 64)
|
||||
lastModified := time.UnixMilli(ms)
|
||||
if lastModified.After(ifModifiedSince) {
|
||||
if lib.LastScanAt.After(ifModifiedSince) {
|
||||
indexes, err = api.ds.Artist(ctx).GetIndex()
|
||||
if err != nil {
|
||||
log.Error(ctx, "Error retrieving Indexes", err)
|
||||
@@ -55,7 +46,7 @@ func (api *Router) getArtistIndex(r *http.Request, libId int, ifModifiedSince ti
|
||||
|
||||
res := &responses.Indexes{
|
||||
IgnoredArticles: conf.Server.IgnoredArticles,
|
||||
LastModified: lastModified.UnixMilli(),
|
||||
LastModified: lib.LastScanAt.UnixMilli(),
|
||||
}
|
||||
|
||||
res.Index = make([]responses.Index, len(indexes))
|
||||
|
||||
Reference in New Issue
Block a user