mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-14 14:22:28 +03:00
fix: create default transcodings on existing installations
This commit is contained in:
parent
bc1f767123
commit
811703ab60
@ -12,6 +12,7 @@ type Transcodings []Transcoding
|
|||||||
|
|
||||||
type TranscodingRepository interface {
|
type TranscodingRepository interface {
|
||||||
Get(id string) (*Transcoding, error)
|
Get(id string) (*Transcoding, error)
|
||||||
|
CountAll(...QueryOptions) (int64, error)
|
||||||
Put(*Transcoding) error
|
Put(*Transcoding) error
|
||||||
FindByFormat(format string) (*Transcoding, error)
|
FindByFormat(format string) (*Transcoding, error)
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,10 @@ func (r *transcodingRepository) Get(id string) (*model.Transcoding, error) {
|
|||||||
return &res, err
|
return &res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *transcodingRepository) CountAll(qo ...model.QueryOptions) (int64, error) {
|
||||||
|
return r.count(Select(), qo...)
|
||||||
|
}
|
||||||
|
|
||||||
func (r *transcodingRepository) FindByFormat(format string) (*model.Transcoding, error) {
|
func (r *transcodingRepository) FindByFormat(format string) (*model.Transcoding, error) {
|
||||||
sel := r.newSelect().Columns("*").Where(Eq{"target_format": format})
|
sel := r.newSelect().Columns("*").Where(Eq{"target_format": format})
|
||||||
var res model.Transcoding
|
var res model.Transcoding
|
||||||
|
@ -14,6 +14,10 @@ import (
|
|||||||
|
|
||||||
func initialSetup(ds model.DataStore) {
|
func initialSetup(ds model.DataStore) {
|
||||||
_ = ds.WithTx(func(tx model.DataStore) error {
|
_ = ds.WithTx(func(tx model.DataStore) error {
|
||||||
|
if err := createDefaultTranscodings(ds); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
_, err := ds.Property(nil).Get(consts.InitialSetupFlagKey)
|
_, err := ds.Property(nil).Get(consts.InitialSetupFlagKey)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
@ -29,10 +33,6 @@ func initialSetup(ds model.DataStore) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = createDefaultTranscodings(ds); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ds.Property(nil).Put(consts.InitialSetupFlagKey, time.Now().String())
|
err = ds.Property(nil).Put(consts.InitialSetupFlagKey, time.Now().String())
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
@ -83,6 +83,10 @@ func createJWTSecret(ds model.DataStore) error {
|
|||||||
|
|
||||||
func createDefaultTranscodings(ds model.DataStore) error {
|
func createDefaultTranscodings(ds model.DataStore) error {
|
||||||
repo := ds.Transcoding(nil)
|
repo := ds.Transcoding(nil)
|
||||||
|
c, _ := repo.CountAll()
|
||||||
|
if c != 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
for _, d := range consts.DefaultTranscodings {
|
for _, d := range consts.DefaultTranscodings {
|
||||||
var j []byte
|
var j []byte
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user