Optimized import, only updating changed data and purging old data

This commit is contained in:
Deluan
2016-03-08 14:18:17 -05:00
parent df9687bf02
commit 46e7627fd3
13 changed files with 253 additions and 55 deletions
+7 -6
View File
@@ -3,16 +3,17 @@ package scanner
import (
"crypto/md5"
"fmt"
"github.com/astaxie/beego"
"github.com/deluan/gosonic/domain"
"github.com/deluan/itl"
"github.com/dhowden/tag"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/astaxie/beego"
"github.com/deluan/gosonic/domain"
"github.com/deluan/itl"
"github.com/dhowden/tag"
)
type ItunesScanner struct {
@@ -30,7 +31,7 @@ func (s *ItunesScanner) ScanLibrary(lastModifiedSince time.Time, path string) (i
if err != nil {
return 0, err
}
beego.Info("Loaded", len(l.Tracks), "tracks")
beego.Debug("Loaded", len(l.Tracks), "tracks")
s.lastModifiedSince = lastModifiedSince
s.mediaFiles = make(map[string]*domain.MediaFile)
@@ -46,7 +47,7 @@ func (s *ItunesScanner) ScanLibrary(lastModifiedSince time.Time, path string) (i
}
i++
if i%1000 == 0 {
beego.Info("Processed", i, "tracks.", len(s.artists), "artists,", len(s.albums), "albums", len(s.mediaFiles), "songs")
beego.Debug("Processed", i, "tracks.", len(s.artists), "artists,", len(s.albums), "albums", len(s.mediaFiles), "songs")
}
}
return len(l.Tracks), nil