diff --git a/model/mediafile.go b/model/mediafile.go index d29a2a509..3350c633c 100644 --- a/model/mediafile.go +++ b/model/mediafile.go @@ -27,6 +27,7 @@ type MediaFile struct { PID string `structs:"pid" json:"-" hash:"ignore"` LibraryID int `structs:"library_id" json:"libraryId" hash:"ignore"` LibraryPath string `structs:"-" json:"libraryPath" hash:"-"` + LibraryName string `structs:"-" json:"libraryName" hash:"-"` FolderID string `structs:"folder_id" json:"folderId" hash:"ignore"` Path string `structs:"path" json:"path" hash:"ignore"` Title string `structs:"title" json:"title"` diff --git a/persistence/mediafile_repository.go b/persistence/mediafile_repository.go index ed74436d3..1095d5f5d 100644 --- a/persistence/mediafile_repository.go +++ b/persistence/mediafile_repository.go @@ -134,7 +134,7 @@ func (r *mediaFileRepository) Put(m *model.MediaFile) error { } func (r *mediaFileRepository) selectMediaFile(options ...model.QueryOptions) SelectBuilder { - sql := r.newSelect(options...).Columns("media_file.*", "library.path as library_path"). + sql := r.newSelect(options...).Columns("media_file.*", "library.path as library_path", "library.name as library_name"). LeftJoin("library on media_file.library_id = library.id") sql = r.withAnnotation(sql, "media_file.id") sql = r.withBookmark(sql, "media_file.id") @@ -274,7 +274,7 @@ func (r *mediaFileRepository) GetMissingAndMatching(libId int) (model.MediaFileC if err != nil { return nil, err } - sel := r.newSelect().Columns("media_file.*", "library.path as library_path"). + sel := r.newSelect().Columns("media_file.*", "library.path as library_path", "library.name as library_name"). LeftJoin("library on media_file.library_id = library.id"). Where("pid in ("+subQText+")", subQArgs...). Where(Or{ diff --git a/persistence/persistence_suite_test.go b/persistence/persistence_suite_test.go index 7edfeee1f..e196ddd8a 100644 --- a/persistence/persistence_suite_test.go +++ b/persistence/persistence_suite_test.go @@ -34,6 +34,7 @@ func mf(mf model.MediaFile) model.MediaFile { mf.Tags = model.Tags{} mf.LibraryID = 1 mf.LibraryPath = "music" // Default folder + mf.LibraryName = "Music Library" mf.Participants = model.Participants{ model.RoleArtist: model.ParticipantList{ model.Participant{Artist: model.Artist{ID: mf.ArtistID, Name: mf.Artist}}, diff --git a/persistence/playlist_repository.go b/persistence/playlist_repository.go index bdaaeeddb..faf5b1c62 100644 --- a/persistence/playlist_repository.go +++ b/persistence/playlist_repository.go @@ -389,6 +389,7 @@ func (r *playlistRepository) loadTracks(sel SelectBuilder, id string) (model.Pla "f.*", "playlist_tracks.*", "library.path as library_path", + "library.name as library_name", ). LeftJoin("annotation on (" + "annotation.item_id = media_file_id" +