Big Importer/Scanner refactor
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
)
|
||||
|
||||
@@ -16,7 +17,7 @@ func NewAlbumRepository() domain.AlbumRepository {
|
||||
|
||||
func (r *albumRepository) Put(m *domain.Album) error {
|
||||
if m.Id == "" {
|
||||
m.Id = r.NewId(m.ArtistId, m.Name)
|
||||
return errors.New("Album Id is not set")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
)
|
||||
|
||||
@@ -16,7 +17,7 @@ func NewArtistRepository() domain.ArtistRepository {
|
||||
|
||||
func (r *artistRepository) Put(m *domain.Artist) error {
|
||||
if m.Id == "" {
|
||||
m.Id = r.NewId(m.Name)
|
||||
return errors.New("Artist Id is not set")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
}
|
||||
@@ -32,4 +33,4 @@ func (r *artistRepository) GetByName(name string) (*domain.Artist, error) {
|
||||
return r.Get(id)
|
||||
}
|
||||
|
||||
var _ domain.ArtistRepository = (*artistRepository)(nil)
|
||||
var _ domain.ArtistRepository = (*artistRepository)(nil)
|
||||
|
||||
@@ -18,7 +18,7 @@ func NewArtistIndexRepository() domain.ArtistIndexRepository {
|
||||
|
||||
func (r *artistIndexRepository) Put(m *domain.ArtistIndex) error {
|
||||
if m.Id == "" {
|
||||
return errors.New("Id is not set")
|
||||
return errors.New("Index Id is not set")
|
||||
}
|
||||
sort.Sort(m.Artists)
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
@@ -32,8 +32,8 @@ func (r *artistIndexRepository) Get(id string) (*domain.ArtistIndex, error) {
|
||||
|
||||
func (r *artistIndexRepository) GetAll() (domain.ArtistIndexes, error) {
|
||||
var indices = make(domain.ArtistIndexes, 0)
|
||||
err := r.loadAll(&indices, domain.QueryOptions{Alpha:true})
|
||||
err := r.loadAll(&indices, domain.QueryOptions{Alpha: true})
|
||||
return indices, err
|
||||
}
|
||||
|
||||
var _ domain.ArtistIndexRepository = (*artistIndexRepository)(nil)
|
||||
var _ domain.ArtistIndexRepository = (*artistIndexRepository)(nil)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"sort"
|
||||
)
|
||||
@@ -16,6 +17,9 @@ func NewMediaFileRepository() domain.MediaFileRepository {
|
||||
}
|
||||
|
||||
func (r *mediaFileRepository) Put(m *domain.MediaFile) error {
|
||||
if m.Id == "" {
|
||||
return errors.New("MediaFile Id is not set")
|
||||
}
|
||||
return r.saveOrUpdate(m.Id, m)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user