mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-12 13:18:40 +01:00
Merge remote-tracking branch 'origin/master' into pr5949
# Conflicts: # cmd/wire_gen.go
This commit is contained in:
commit
bd6a3fb16e
58 changed files with 1732 additions and 543 deletions
|
|
@ -93,6 +93,8 @@ func (r *libraryRepository) Put(ctx context.Context, l *model.Library, colsToUpd
|
|||
"path": l.Path,
|
||||
"remote_path": l.RemotePath,
|
||||
"default_new_users": l.DefaultNewUsers,
|
||||
"pid_album": l.PIDAlbum,
|
||||
"pid_track": l.PIDTrack,
|
||||
}, colsToUpdate...)
|
||||
cols["updated_at"] = l.UpdatedAt
|
||||
sq := Update(r.tableName).SetMap(cols).Where(Eq{"id": l.ID})
|
||||
|
|
@ -176,6 +178,15 @@ func (r *libraryRepository) ScanEnd(ctx context.Context, id int) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (r *libraryRepository) SetScannedPID(ctx context.Context, id int, pid model.PIDConfig) error {
|
||||
sq := Update(r.tableName).
|
||||
Set("scanned_pid_album", pid.Album).
|
||||
Set("scanned_pid_track", pid.Track).
|
||||
Where(Eq{"id": id})
|
||||
_, err := r.executeSQL(ctx, sq)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *libraryRepository) ScanInProgress(ctx context.Context) (bool, error) {
|
||||
query := r.newSelect(ctx).Where(NotEq{"last_scan_started_at": time.Time{}})
|
||||
count, err := r.count(ctx, query)
|
||||
|
|
|
|||
|
|
@ -270,6 +270,38 @@ var _ = Describe("LibraryRepository", func() {
|
|||
})
|
||||
})
|
||||
|
||||
Describe("PID config", func() {
|
||||
It("stores the overrides, and Put never touches the scanned specs", func() {
|
||||
lib := &model.Library{Name: "PID Library", Path: "/music/pid", PIDAlbum: "folder", PIDTrack: "title"}
|
||||
Expect(repo.Put(ctx, lib)).To(Succeed())
|
||||
Expect(repo.SetScannedPID(ctx, lib.ID, model.PIDConfig{Album: "folder", Track: "title"})).To(Succeed())
|
||||
|
||||
// An update coming from the REST API has no scanned specs. It must not clear them
|
||||
update := &model.Library{ID: lib.ID, Name: "PID Library", Path: "/music/pid", PIDTrack: "title"}
|
||||
Expect(repo.Put(ctx, update)).To(Succeed())
|
||||
|
||||
saved, err := repo.Get(ctx, lib.ID)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(saved.PIDAlbum).To(BeEmpty())
|
||||
Expect(saved.PIDTrack).To(Equal("title"))
|
||||
Expect(saved.ScannedPIDAlbum).To(Equal("folder"))
|
||||
Expect(saved.ScannedPIDTrack).To(Equal("title"))
|
||||
})
|
||||
|
||||
It("keeps the overrides when a partial update does not send them", func() {
|
||||
lib := &model.Library{Name: "Partial", Path: "/music/partial", PIDAlbum: "folder", PIDTrack: "title"}
|
||||
Expect(repo.Put(ctx, lib)).To(Succeed())
|
||||
|
||||
Expect(repo.Put(ctx, &model.Library{ID: lib.ID, Name: "Renamed"}, "name")).To(Succeed())
|
||||
|
||||
saved, err := repo.Get(ctx, lib.ID)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(saved.Name).To(Equal("Renamed"))
|
||||
Expect(saved.PIDAlbum).To(Equal("folder"))
|
||||
Expect(saved.PIDTrack).To(Equal("title"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Delete", func() {
|
||||
var adminRepo model.LibraryRepository
|
||||
var artistRepo model.ArtistRepository
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue