mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 13:07:36 +03:00
Remove unused code
This commit is contained in:
parent
1f58bf47d6
commit
ed31b6fa31
4 changed files with 0 additions and 102 deletions
|
@ -1,8 +0,0 @@
|
|||
package model
|
||||
|
||||
type ChecksumMap map[string]string
|
||||
|
||||
type ChecksumRepository interface {
|
||||
GetData() (ChecksumMap, error)
|
||||
SetData(newSums ChecksumMap) error
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
)
|
||||
|
||||
type checkSumRepository struct {
|
||||
ormer orm.Ormer
|
||||
}
|
||||
|
||||
const checkSumId = "1"
|
||||
|
||||
type checksum struct {
|
||||
ID string `orm:"pk;column(id)"`
|
||||
Sum string
|
||||
}
|
||||
|
||||
func NewCheckSumRepository(o orm.Ormer) model.ChecksumRepository {
|
||||
r := &checkSumRepository{ormer: o}
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *checkSumRepository) GetData() (model.ChecksumMap, error) {
|
||||
loadedData := make(map[string]string)
|
||||
|
||||
var all []checksum
|
||||
_, err := r.ormer.QueryTable(&checksum{}).Limit(-1).All(&all)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, cks := range all {
|
||||
loadedData[cks.ID] = cks.Sum
|
||||
}
|
||||
|
||||
return loadedData, nil
|
||||
}
|
||||
|
||||
func (r *checkSumRepository) SetData(newSums model.ChecksumMap) error {
|
||||
_, err := r.ormer.Raw("delete from checksum").Exec()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var checksums []checksum
|
||||
for k, v := range newSums {
|
||||
cks := checksum{ID: k, Sum: v}
|
||||
checksums = append(checksums, cks)
|
||||
}
|
||||
_, err = r.ormer.InsertMulti(batchSize, &checksums)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ model.ChecksumRepository = (*checkSumRepository)(nil)
|
|
@ -1,35 +0,0 @@
|
|||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/orm"
|
||||
"github.com/cloudsonic/sonic-server/model"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("ChecksumRepository", func() {
|
||||
var repo model.ChecksumRepository
|
||||
|
||||
BeforeEach(func() {
|
||||
repo = NewCheckSumRepository(orm.NewOrm())
|
||||
err := repo.SetData(map[string]string{
|
||||
"a": "AAA", "b": "BBB",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
|
||||
It("can retrieve data", func() {
|
||||
sums, err := repo.GetData()
|
||||
Expect(err).To(BeNil())
|
||||
Expect(sums["b"]).To(Equal("BBB"))
|
||||
})
|
||||
|
||||
It("persists data", func() {
|
||||
newRepo := NewCheckSumRepository(orm.NewOrm())
|
||||
sums, err := newRepo.GetData()
|
||||
Expect(err).To(BeNil())
|
||||
Expect(sums["b"]).To(Equal("BBB"))
|
||||
})
|
||||
})
|
|
@ -165,6 +165,5 @@ func init() {
|
|||
registerModel(model.User{}, new(user))
|
||||
registerModel(model.Annotation{}, new(annotation))
|
||||
|
||||
orm.RegisterModel(new(checksum))
|
||||
orm.RegisterModel(new(search))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue