diff --git a/cmd/gonicembed/main.go b/cmd/gonicembed/main.go index 69813a0..d5c8074 100644 --- a/cmd/gonicembed/main.go +++ b/cmd/gonicembed/main.go @@ -18,9 +18,10 @@ import ( // once i had this written with ~100% text/template but it was very // slow. now this thing is not nice on the eyes or easy to change // but it's pretty fast. which i needed it to for live reloading stuff + const ( byteCols = 24 - // begin file template + // ** begin file template fileHeader = `// file generated with embed tool // do not edit // %s @@ -33,7 +34,7 @@ type EmbeddedAsset struct { var %s = map[string]*EmbeddedAsset{` fileFooter = ` }` - // begin asset template + // ** begin asset template assetHeader = ` %q: &EmbeddedAsset{ ModTime: time.Unix(%d, 0), @@ -104,13 +105,11 @@ func processAssets(c *config, files []string) error { return errors.Wrap(err, "opening asset") } defer data.Close() - processAsset( - c, - &file{ - data: data, - path: path, - modTime: info.ModTime(), - }, + processAsset(c, &file{ + data: data, + path: path, + modTime: info.ModTime(), + }, outWriter, ) } diff --git a/db/migrations.go b/db/migrations.go index 026c0ea..394c4a0 100644 --- a/db/migrations.go +++ b/db/migrations.go @@ -7,6 +7,7 @@ import ( ) // $ date '+%Y%m%d%H%M' + // not really a migration var migrationInitSchema = gormigrate.Migration{ ID: "202002192100", diff --git a/scanner/scanner.go b/scanner/scanner.go index c5365e9..5350fd8 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -126,14 +126,14 @@ func (s *Scanner) Start() error { s.db.Exec(` DELETE FROM albums WHERE tag_artist_id NOT NULL - AND NOT EXISTS ( SELECT 1 FROM tracks - WHERE tracks.album_id=albums.id + AND NOT EXISTS ( SELECT 1 FROM tracks + WHERE tracks.album_id=albums.id )`) // delete artists without albums s.db.Exec(` DELETE FROM artists - WHERE NOT EXISTS ( SELECT 1 from albums - WHERE albums.tag_artist_id=artists.id + WHERE NOT EXISTS ( SELECT 1 from albums + WHERE albums.tag_artist_id=artists.id )`) // finish up strNow := strconv.FormatInt(time.Now().Unix(), 10) diff --git a/scanner/tags/tags.go b/scanner/tags/tags.go index 1655af3..21b703e 100644 --- a/scanner/tags/tags.go +++ b/scanner/tags/tags.go @@ -32,6 +32,7 @@ func (t *Tags) firstTag(keys ...string) string { } return "" } + func (t *Tags) Title() string { return t.firstTag("title") } func (t *Tags) BrainzID() string { return t.firstTag("musicbrainz_trackid") } func (t *Tags) Artist() string { return t.firstTag("artist") } @@ -44,6 +45,7 @@ func (t *Tags) TrackNumber() int { return intSep(t.firstTag("tracknumber"), func (t *Tags) DiscNumber() int { return intSep(t.firstTag("discnumber"), "/") } // eg. 1/2 func (t *Tags) Length() int { return t.props.Length } func (t *Tags) Bitrate() int { return t.props.Bitrate } + func intSep(in, sep string) int { if in == "" { return 0