Polishing
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/deluan/gosonic/api/responses"
|
"github.com/deluan/gosonic/api/responses"
|
||||||
"github.com/deluan/gosonic/consts"
|
|
||||||
"github.com/deluan/gosonic/domain"
|
"github.com/deluan/gosonic/domain"
|
||||||
"github.com/deluan/gosonic/engine"
|
"github.com/deluan/gosonic/engine"
|
||||||
"github.com/deluan/gosonic/persistence"
|
"github.com/deluan/gosonic/persistence"
|
||||||
@@ -46,7 +45,7 @@ func TestGetIndexes(t *testing.T) {
|
|||||||
|
|
||||||
mockRepo.SetData("[]", 0)
|
mockRepo.SetData("[]", 0)
|
||||||
mockRepo.SetError(false)
|
mockRepo.SetError(false)
|
||||||
propRepo.Put(consts.LastScan, "1")
|
propRepo.Put(engine.PropLastScan, "1")
|
||||||
propRepo.SetError(false)
|
propRepo.SetError(false)
|
||||||
|
|
||||||
Convey("Subject: GetIndexes Endpoint", t, func() {
|
Convey("Subject: GetIndexes Endpoint", t, func() {
|
||||||
@@ -88,7 +87,7 @@ func TestGetIndexes(t *testing.T) {
|
|||||||
mockRepo.SetData(`[{"Id": "A","Artists": [
|
mockRepo.SetData(`[{"Id": "A","Artists": [
|
||||||
{"ArtistId": "21", "Artist": "Afrolicious"}
|
{"ArtistId": "21", "Artist": "Afrolicious"}
|
||||||
]}]`, 2)
|
]}]`, 2)
|
||||||
propRepo.Put(consts.LastScan, "1")
|
propRepo.Put(engine.PropLastScan, "1")
|
||||||
|
|
||||||
_, w := Get(AddParams("/rest/getIndexes.view", "ifModifiedSince=2"), "TestGetIndexes")
|
_, w := Get(AddParams("/rest/getIndexes.view", "ifModifiedSince=2"), "TestGetIndexes")
|
||||||
|
|
||||||
@@ -98,7 +97,7 @@ func TestGetIndexes(t *testing.T) {
|
|||||||
mockRepo.SetData(`[{"Id": "A","Artists": [
|
mockRepo.SetData(`[{"Id": "A","Artists": [
|
||||||
{"ArtistId": "21", "Artist": "Afrolicious"}
|
{"ArtistId": "21", "Artist": "Afrolicious"}
|
||||||
]}]`, 2)
|
]}]`, 2)
|
||||||
propRepo.Put(consts.LastScan, "1")
|
propRepo.Put(engine.PropLastScan, "1")
|
||||||
|
|
||||||
_, w := Get(AddParams("/rest/getIndexes.view", "ifModifiedSince=1"), "TestGetIndexes")
|
_, w := Get(AddParams("/rest/getIndexes.view", "ifModifiedSince=1"), "TestGetIndexes")
|
||||||
|
|
||||||
@@ -107,7 +106,7 @@ func TestGetIndexes(t *testing.T) {
|
|||||||
Reset(func() {
|
Reset(func() {
|
||||||
mockRepo.SetData("[]", 0)
|
mockRepo.SetData("[]", 0)
|
||||||
mockRepo.SetError(false)
|
mockRepo.SetError(false)
|
||||||
propRepo.Put(consts.LastScan, "1")
|
propRepo.Put(engine.PropLastScan, "1")
|
||||||
propRepo.SetError(false)
|
propRepo.SetError(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package consts
|
|
||||||
|
|
||||||
const (
|
|
||||||
LastScan = "LastScan"
|
|
||||||
)
|
|
||||||
+1
-2
@@ -7,7 +7,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/deluan/gosonic/consts"
|
|
||||||
"github.com/deluan/gosonic/domain"
|
"github.com/deluan/gosonic/domain"
|
||||||
"github.com/deluan/gosonic/utils"
|
"github.com/deluan/gosonic/utils"
|
||||||
)
|
)
|
||||||
@@ -37,7 +36,7 @@ func (b *browser) MediaFolders() (domain.MediaFolders, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *browser) Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time.Time, error) {
|
func (b *browser) Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time.Time, error) {
|
||||||
l, err := b.propRepo.DefaultGet(consts.LastScan, "-1")
|
l, err := b.propRepo.DefaultGet(PropLastScan, "-1")
|
||||||
ms, _ := strconv.ParseInt(l, 10, 64)
|
ms, _ := strconv.ParseInt(l, 10, 64)
|
||||||
lastModified := utils.ToTime(ms)
|
lastModified := utils.ToTime(ms)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package engine
|
package engine
|
||||||
|
|
||||||
|
const (
|
||||||
|
PropLastScan = "LastScan"
|
||||||
|
)
|
||||||
|
|
||||||
type Property struct {
|
type Property struct {
|
||||||
Id string
|
Id string
|
||||||
Value string
|
Value string
|
||||||
|
|||||||
+2
-3
@@ -8,7 +8,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/deluan/gosonic/consts"
|
|
||||||
"github.com/deluan/gosonic/domain"
|
"github.com/deluan/gosonic/domain"
|
||||||
"github.com/deluan/gosonic/engine"
|
"github.com/deluan/gosonic/engine"
|
||||||
"github.com/deluan/gosonic/utils"
|
"github.com/deluan/gosonic/utils"
|
||||||
@@ -116,7 +115,7 @@ func (i *Importer) Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Importer) lastModifiedSince() time.Time {
|
func (i *Importer) lastModifiedSince() time.Time {
|
||||||
ms, err := i.propertyRepo.Get(consts.LastScan)
|
ms, err := i.propertyRepo.Get(engine.PropLastScan)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beego.Warn("Couldn't read LastScan:", err)
|
beego.Warn("Couldn't read LastScan:", err)
|
||||||
return time.Time{}
|
return time.Time{}
|
||||||
@@ -263,7 +262,7 @@ func (i *Importer) importLibrary() (err error) {
|
|||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
millis := time.Now().UnixNano() / int64(time.Millisecond)
|
millis := time.Now().UnixNano() / int64(time.Millisecond)
|
||||||
i.propertyRepo.Put(consts.LastScan, fmt.Sprint(millis))
|
i.propertyRepo.Put(engine.PropLastScan, fmt.Sprint(millis))
|
||||||
beego.Debug("LastScan timestamp:", millis)
|
beego.Debug("LastScan timestamp:", millis)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user