mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Add scanner status
This commit is contained in:
parent
c0ec0b28b9
commit
af7eaa2b7a
5 changed files with 170 additions and 52 deletions
22
cmd/scan.go
22
cmd/scan.go
|
@ -1,8 +1,11 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/deluan/navidrome/conf"
|
||||
"github.com/deluan/navidrome/log"
|
||||
"github.com/deluan/navidrome/scanner"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -22,12 +25,23 @@ var scanCmd = &cobra.Command{
|
|||
},
|
||||
}
|
||||
|
||||
func waitScanToFinish(scanner scanner.Scanner) {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
ticker := time.Tick(100 * time.Millisecond)
|
||||
for {
|
||||
if !scanner.Scanning() {
|
||||
return
|
||||
}
|
||||
<-ticker
|
||||
}
|
||||
}
|
||||
|
||||
func runScanner() {
|
||||
scanner := CreateScanner(conf.Server.MusicFolder)
|
||||
err := scanner.RescanAll(fullRescan)
|
||||
if err != nil {
|
||||
log.Error("Error scanning media folder", "folder", conf.Server.MusicFolder, err)
|
||||
}
|
||||
go func() { _ = scanner.Start(0) }()
|
||||
scanner.RescanAll(fullRescan)
|
||||
waitScanToFinish(scanner)
|
||||
scanner.Stop()
|
||||
if fullRescan {
|
||||
log.Info("Finished full rescan")
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue