move get funcs to db

This commit is contained in:
sentriz
2019-07-05 17:10:11 +01:00
parent 1ab24db5d7
commit b6b3043765
13 changed files with 79 additions and 73 deletions

View File

@@ -14,6 +14,7 @@ import (
"github.com/pkg/errors"
"github.com/rainycape/unidecode"
"github.com/sentriz/gonic/db"
"github.com/sentriz/gonic/mime"
"github.com/sentriz/gonic/model"
"github.com/sentriz/gonic/scanner/stack"
@@ -51,14 +52,14 @@ func decoded(in string) string {
return result
}
func withTx(db *gorm.DB, cb func(tx *gorm.DB)) {
func withTx(db *db.DB, cb func(tx *gorm.DB)) {
tx := db.Begin()
defer tx.Commit()
cb(tx)
}
type Scanner struct {
db *gorm.DB
db *db.DB
musicPath string
// these two are for the transaction we do for every folder.
// the boolean is there so we dont begin or commit multiple
@@ -78,7 +79,7 @@ type Scanner struct {
seenTracksErr int // n tracks we we couldn't scan
}
func New(db *gorm.DB, musicPath string) *Scanner {
func New(db *db.DB, musicPath string) *Scanner {
return &Scanner{
db: db,
musicPath: musicPath,