mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-14 03:07:24 +03:00
Task for continuously check for iTunes Library updates
This commit is contained in:
parent
12b0350d3e
commit
329297dab8
@ -26,12 +26,13 @@ type Scanner interface {
|
||||
type tempIndex map[string]domain.ArtistInfo
|
||||
|
||||
var (
|
||||
inProgress = make(chan int)
|
||||
lastUpdated time.Time
|
||||
inProgress chan int
|
||||
lastCheck time.Time
|
||||
itunesLibrary string
|
||||
)
|
||||
|
||||
func init() {
|
||||
inProgress = make(chan int)
|
||||
startImport()
|
||||
}
|
||||
|
||||
@ -39,7 +40,7 @@ func CheckForUpdates(force bool) {
|
||||
<-inProgress
|
||||
|
||||
if force {
|
||||
lastUpdated = time.Time{}
|
||||
lastCheck = time.Time{}
|
||||
}
|
||||
|
||||
startImport()
|
||||
@ -55,11 +56,11 @@ func startImport() {
|
||||
beego.Error(err)
|
||||
return
|
||||
}
|
||||
if lastUpdated.After(info.ModTime()) {
|
||||
if lastCheck.After(info.ModTime()) {
|
||||
inProgress <- 1
|
||||
return
|
||||
}
|
||||
lastUpdated = time.Now()
|
||||
lastCheck = time.Now()
|
||||
|
||||
// TODO Move all to DI
|
||||
i := &Importer{mediaFolder: beego.AppConfig.String("musicFolder")}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/toolbox"
|
||||
"github.com/deluan/gosonic/scanner"
|
||||
)
|
||||
@ -14,6 +17,9 @@ func init() {
|
||||
})
|
||||
|
||||
toolbox.AddTask(TaskItunesScan, scan)
|
||||
toolbox.StartTask()
|
||||
defer toolbox.DeleteTask(TaskItunesScan)
|
||||
go func() {
|
||||
time.Sleep(20 * time.Second)
|
||||
beego.Debug("Starting", TaskItunesScan)
|
||||
toolbox.StartTask()
|
||||
}()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user