Merge remote-tracking branch 'origin' into ldap_auth
This commit is contained in:
No files matched your search
@@ -29,15 +29,15 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Golang with cache
|
||||
uses: magnetikonline/action-golang-cache@v5
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
uses: golangci/golangci-lint-action@v9
|
||||
with:
|
||||
install-mode: goinstall
|
||||
version: v2.4.0
|
||||
version: v2.6.1
|
||||
- name: Test
|
||||
run: go test ./...
|
||||
build-docker:
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
|
||||
@@ -10,15 +10,15 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Golang with cache
|
||||
uses: magnetikonline/action-golang-cache@v5
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
uses: golangci/golangci-lint-action@v9
|
||||
with:
|
||||
install-mode: goinstall
|
||||
version: v2.4.0
|
||||
version: v2.6.1
|
||||
- name: Test
|
||||
run: go test ./...
|
||||
release-please:
|
||||
@@ -57,8 +57,8 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Golang with cache
|
||||
uses: magnetikonline/action-golang-cache@v5
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- name: Build
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Docker Buildx
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login into DockerHub
|
||||
run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||
|
||||
@@ -11,14 +11,14 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Golang with cache
|
||||
uses: magnetikonline/action-golang-cache@v5
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
- name: Lint
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
uses: golangci/golangci-lint-action@v9
|
||||
with:
|
||||
install-mode: goinstall
|
||||
version: v2.4.0
|
||||
version: v2.6.1
|
||||
- name: Test
|
||||
run: go test ./...
|
||||
@@ -1,5 +1,64 @@
|
||||
# Changelog
|
||||
|
||||
## [0.19.0](https://www.github.com/sentriz/gonic/compare/v0.18.0...v0.19.0) (2025-10-11)
|
||||
|
||||
This release uses WebAssesmby for the [tagging](https://github.com/sentriz/go-taglib) and [database](https://github.com/ncruces/go-sqlite3) backends. This means that gonic no longer requires Cgo or external dependencies to build. As a result, static binaries will be available in the releases page, and Docker images for more architectures. Performance of scanning and tagging should also be improved.
|
||||
|
||||
### Features
|
||||
|
||||
* **build:** add Cgo free database ([505f7d8](https://www.github.com/sentriz/gonic/commit/505f7d8ae6116c5dc1cfa50a5caba6333672be20))
|
||||
* **build:** add Cgo free tagging backend ([7802e20](https://www.github.com/sentriz/gonic/commit/7802e20e7214e1912fc84bb29c877984b99913c9))
|
||||
* **ci:** merge nightly and debug workflows ([ca85eed](https://www.github.com/sentriz/gonic/commit/ca85eed4c156c5370c1e3e4c7fbc31d4c1811f57))
|
||||
* **ci:** remove Cgo dependencies, cross compile without QEMU, upload static binaries ([e3db819](https://www.github.com/sentriz/gonic/commit/e3db819d8fd5ae14332c56ab7cebc01d46a6c76b))
|
||||
* **ffprobe:** add more supported file types ([8e7820a](https://www.github.com/sentriz/gonic/commit/8e7820a72e2360e3b5808299123fd5a686c084e8))
|
||||
* **gonic:** add `scan-embedded-cover-enabled` flag ([c69cb8c](https://www.github.com/sentriz/gonic/commit/c69cb8cf35203c6db15d3c1bd68a86cb91108b40))
|
||||
* **gonic:** use wrtag/normtag for nag normalisation ([aba758f](https://www.github.com/sentriz/gonic/commit/aba758f2ba6e6d20887a36a0cba80127c2b110a9))
|
||||
* **subsonic:** also read unsynced lyrics from .txt files and tag metadata ([eb0d8fd](https://www.github.com/sentriz/gonic/commit/eb0d8fd1c710bf0367348873858662c39515b676)), closes [#593](https://www.github.com/sentriz/gonic/issues/593)
|
||||
* **subsonic:** keep original cover file format when caching ([#609](https://www.github.com/sentriz/gonic/issues/609)) ([1af4ce3](https://www.github.com/sentriz/gonic/commit/1af4ce35873ff17dc6331e0d7c0e0385213b53b3)), closes [#11](https://www.github.com/sentriz/gonic/issues/11)
|
||||
* **subsonic:** return genres for getAlbumListTwo2 ([3909e9b](https://www.github.com/sentriz/gonic/commit/3909e9b5bdbc3deb1b5f48ff6f04b3d865a1b1bc)), closes [#605](https://www.github.com/sentriz/gonic/issues/605)
|
||||
* **subsonic:** support embedded cover art ([ec7cffd](https://www.github.com/sentriz/gonic/commit/ec7cffdd57f235adce93b7faf1998fdc9a164c52)), closes [#11](https://www.github.com/sentriz/gonic/issues/11) [#556](https://www.github.com/sentriz/gonic/issues/556)
|
||||
* **subsonic:** support embedded track level cover art ([d66814b](https://www.github.com/sentriz/gonic/commit/d66814bfd1d39ba92c6c368c0006052451675454)), closes [#11](https://www.github.com/sentriz/gonic/issues/11)
|
||||
* **tags:** add ffprobe reader ([3a9c03a](https://www.github.com/sentriz/gonic/commit/3a9c03ac88b6e6476206a87e3703e247c965e7c9))
|
||||
* **tags:** add Properties.HasCover ([bc0b6c0](https://www.github.com/sentriz/gonic/commit/bc0b6c0da4738c3ee8f40525e2ed1d85c51f927a))
|
||||
* **tags:** add ReadCover interface method ([e413bc3](https://www.github.com/sentriz/gonic/commit/e413bc35ded9463b245ff913fb2d90ee80ea3184))
|
||||
|
||||
### ⚠ Note to package maintainers
|
||||
|
||||
- The `sqlite-dev` and `libtag-dev` (or your distro's equivalents) packages are **no longer required**; please remove them from package dependencies.
|
||||
- Build with `CGO_ENABLED=0` to produce static binaries.
|
||||
|
||||
gonic now vendors reproducible WebAssembly backends for TagLib and SQLite, eliminating Cgo and external system libraries. Builds are fully static, cross-compiling is straightforward, and supply-chain verification is easier.
|
||||
|
||||
Verify the vendored WASM artifacts using Artifact Attestations:
|
||||
- <https://github.com/sentriz/go-taglib/raw/refs/tags/v0.10.4/taglib.wasm> ([Attestations](https://github.com/sentriz/go-taglib/attestations/11402786))
|
||||
- <https://github.com/ncruces/go-sqlite3/raw/refs/tags/v0.29.1/embed/sqlite3.wasm> ([Attestations](https://github.com/ncruces/go-sqlite3/attestations/11344814))
|
||||
|
||||
Example build pipeline:
|
||||
```console
|
||||
$ git clone https://github.com/sentriz/gonic
|
||||
$ cd gonic
|
||||
|
||||
$ sha256sum "$(go list -m -f '{{.Dir}}' go.senan.xyz/taglib)/taglib.wasm"
|
||||
# expected ca5ce04b35f1e6cad8b8d9f00906a4c108ccd004b56e713db5ce69aa69b3805d (https://github.com/sentriz/go-taglib/attestations/11402786)
|
||||
|
||||
$ sha256sum "$(go list -m -f '{{.Dir}}' github.com/ncruces/go-sqlite3)/embed/sqlite3.wasm"
|
||||
# expected 117262b6241d8de78ba564a44383fa1562e52f1a978de269e20a02b3c06c02e3 (https://github.com/ncruces/go-sqlite3/attestations/11344814)
|
||||
|
||||
$ CGO_ENABLED=0 go build ./cmd/gonic/.
|
||||
```
|
||||
|
||||
Opting out of WebAssembly:
|
||||
|
||||
- If you prefer not to use the WebAssembly binaries, you can build with `nowasm`:
|
||||
|
||||
```console
|
||||
$ go build -tags nowasm ./cmd/gonic/.
|
||||
```
|
||||
|
||||
- This mode is not supported, and tagging/scan performance will degrade.
|
||||
- Cgo will be used for sqlite, so sqlite-dev is still required.
|
||||
- `ffprobe` will be used for tagging, so that must be available in `$PATH`. `libtag-dev` is still not used in this mode.
|
||||
|
||||
## [0.18.0](https://www.github.com/sentriz/gonic/compare/v0.17.0...v0.18.0) (2025-09-18)
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
- support for the [album-artist](https://mkoby.com/2007/02/18/artist-versus-album-artist/) tag, to not clutter your artist list with compilation album appearances
|
||||
- written in [go](https://golang.org/), so lightweight and suitable for a raspberry pi, etc. (see ARM images below)
|
||||
- newer salt and token auth
|
||||
- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [symfonium](https://symfonium.app), [dsub](https://f-droid.org/en/packages/github.daneren2005.dsub/), [jamstash](http://jamstash.com/), [subsonic.el](https://git.sr.ht/~amk/subsonic.el), [sublime music](https://github.com/sublime-music/sublime-music), [soundwaves](https://apps.apple.com/us/app/soundwaves/id736139596), [stmp](https://github.com/wildeyedskies/stmp), [termsonic](https://git.sixfoisneuf.fr/termsonic/), [strawberry](https://www.strawberrymusicplayer.org/), and [ultrasonic](https://gitlab.com/ultrasonic/ultrasonic)
|
||||
- tested on [airsonic-refix](https://github.com/tamland/airsonic-refix), [symfonium](https://symfonium.app), [dsub](https://f-droid.org/en/packages/github.daneren2005.dsub/), [jamstash](http://jamstash.com/), [subsonic.el](https://git.sr.ht/~amk/subsonic.el), [sublime music](https://github.com/sublime-music/sublime-music), [soundwaves](https://apps.apple.com/us/app/soundwaves/id736139596), [stmp](https://github.com/wildeyedskies/stmp), [termsonic](https://git.sixfoisneuf.fr/termsonic/), [tempus](https://github.com/eddyizm/tempus/), [strawberry](https://www.strawberrymusicplayer.org/), and [ultrasonic](https://gitlab.com/ultrasonic/ultrasonic)
|
||||
|
||||
## installation
|
||||
|
||||
|
||||
Binary file not shown.
+9
-4
@@ -30,8 +30,10 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"go.senan.xyz/flagconf"
|
||||
|
||||
"go.senan.xyz/gonic"
|
||||
"go.senan.xyz/gonic/db"
|
||||
"go.senan.xyz/gonic/deps"
|
||||
"go.senan.xyz/gonic/handlerutil"
|
||||
"go.senan.xyz/gonic/infocache/albuminfocache"
|
||||
"go.senan.xyz/gonic/infocache/artistinfocache"
|
||||
@@ -101,12 +103,13 @@ func main() {
|
||||
}
|
||||
|
||||
var confMultiValueGenre, confMultiValueArtist, confMultiValueAlbumArtist multiValueSetting
|
||||
flag.Var(&confMultiValueGenre, "multi-value-genre", "setting for mutli-valued genre scanning (optional)")
|
||||
flag.Var(&confMultiValueArtist, "multi-value-artist", "setting for mutli-valued track artist scanning (optional)")
|
||||
flag.Var(&confMultiValueAlbumArtist, "multi-value-album-artist", "setting for mutli-valued album artist scanning (optional)")
|
||||
flag.Var(&confMultiValueGenre, "multi-value-genre", "setting for multi-valued genre scanning (optional)")
|
||||
flag.Var(&confMultiValueArtist, "multi-value-artist", "setting for multi-valued track artist scanning (optional)")
|
||||
flag.Var(&confMultiValueAlbumArtist, "multi-value-album-artist", "setting for multi-valued album artist scanning (optional)")
|
||||
|
||||
confPprof := flag.Bool("pprof", false, "enable the /debug/pprof endpoint (optional)")
|
||||
confExpvar := flag.Bool("expvar", false, "enable the /debug/vars endpoint (optional)")
|
||||
confLogDB := flag.Bool("log-db", false, "enable database query logging (optional)")
|
||||
|
||||
deprecatedConfGenreSplit := flag.String("genre-split", "", "(deprecated, see multi-value settings)")
|
||||
|
||||
@@ -156,7 +159,7 @@ func main() {
|
||||
log.Fatalf("couldn't create covers cache path: %v\n", err)
|
||||
}
|
||||
|
||||
dbc, err := db.New(*confDBPath, db.DefaultOptions())
|
||||
dbc, err := db.New(*confDBPath, deps.DBDriverOptions(), *confLogDB)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening database: %v\n", err)
|
||||
}
|
||||
@@ -200,6 +203,8 @@ func main() {
|
||||
log.Printf(" %-30s %s\n", f.Name, value)
|
||||
})
|
||||
|
||||
tagReader := deps.TagReader
|
||||
|
||||
scannr := scanner.New(
|
||||
ctrlsubsonic.MusicPaths(musicPaths),
|
||||
dbc,
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
//go:build !nowasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
// Cgo-free Wasm database
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
|
||||
// Cgo-free Wasm tagger
|
||||
"go.senan.xyz/gonic/tags/taglib"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var tagReader = taglib.Reader{}
|
||||
@@ -1,14 +0,0 @@
|
||||
//go:build nowasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
// Cgo database
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
||||
// Cgo tagger
|
||||
"go.senan.xyz/gonic/tags/ffprobe"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var tagReader = ffprobe.Reader{}
|
||||
@@ -17,46 +17,40 @@ import (
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||
)
|
||||
|
||||
func DefaultOptions() url.Values {
|
||||
return url.Values{
|
||||
// with this, multiple connections share a single data and schema cache.
|
||||
// see https://www.sqlite.org/sharedcache.html
|
||||
"cache": {"shared"},
|
||||
// with this, the db sleeps for a little while when locked. can prevent
|
||||
// a SQLITE_BUSY. see https://www.sqlite.org/c3ref/busy_timeout.html
|
||||
"_busy_timeout": {"30000"},
|
||||
"_journal_mode": {"WAL"},
|
||||
"_foreign_keys": {"true"},
|
||||
}
|
||||
}
|
||||
|
||||
func mockOptions() url.Values {
|
||||
return url.Values{
|
||||
"_foreign_keys": {"true"},
|
||||
}
|
||||
}
|
||||
|
||||
type DB struct {
|
||||
*gorm.DB
|
||||
}
|
||||
|
||||
func New(path string, options url.Values) (*DB, error) {
|
||||
url := url.URL{
|
||||
Scheme: "file",
|
||||
Opaque: path,
|
||||
func New(path string, opts url.Values, logQueries bool) (*DB, error) {
|
||||
u := url.URL{
|
||||
Scheme: "file",
|
||||
Opaque: path,
|
||||
RawQuery: opts.Encode(),
|
||||
}
|
||||
url.RawQuery = options.Encode()
|
||||
db, err := gorm.Open("sqlite3", url.String())
|
||||
|
||||
db, err := gorm.Open("sqlite3", u.String())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("with gorm: %w", err)
|
||||
}
|
||||
|
||||
db.SetLogger(log.New(os.Stdout, "gorm ", 0))
|
||||
db.DB().SetMaxOpenConns(1)
|
||||
if logQueries {
|
||||
db.LogMode(true)
|
||||
}
|
||||
|
||||
db.DB().SetMaxOpenConns(4)
|
||||
|
||||
return &DB{DB: db}, nil
|
||||
}
|
||||
|
||||
func NewMock() (*DB, error) {
|
||||
return New(":memory:", mockOptions())
|
||||
func NewMock(opts url.Values) (*DB, error) {
|
||||
d, err := New(":memory:", opts, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// in-memory databases can't be shared across multiple connections
|
||||
d.DB.DB().SetMaxOpenConns(1)
|
||||
return d, nil
|
||||
}
|
||||
|
||||
func (db *DB) InsertBulkLeftMany(table string, head []string, left int, col []int) error {
|
||||
@@ -229,7 +223,7 @@ type Track struct {
|
||||
TagTrackNumber int `sql:"default: null"`
|
||||
TagDiscNumber int `sql:"default: null"`
|
||||
TagBrainzID string `sql:"default: null"`
|
||||
TagLyrics string `sql:"default:null"`
|
||||
TagLyrics string `sql:"default: null"`
|
||||
|
||||
ReplayGainTrackGain float32
|
||||
ReplayGainTrackPeak float32
|
||||
|
||||
+3
-2
@@ -7,8 +7,9 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"go.senan.xyz/gonic/deps"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -22,7 +23,7 @@ func TestGetSetting(t *testing.T) {
|
||||
key := SettingKey(randKey())
|
||||
value := "howdy"
|
||||
|
||||
testDB, err := NewMock()
|
||||
testDB, err := NewMock(deps.DBDriverOptions())
|
||||
if err != nil {
|
||||
t.Fatalf("error creating db: %v", err)
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ func (db *DB) Migrate(ctx MigrationContext) error {
|
||||
construct(ctx, "202508261102", migrateAddLyrics),
|
||||
construct(ctx, "202509291741", migrateAddAlbumEmbeddedCoverTrackID),
|
||||
construct(ctx, "202509301448", migrateAddTrackEmbeddedCover),
|
||||
construct(ctx, "202512021147", migrateAlbumAddIndexOnCreatedAt),
|
||||
}
|
||||
|
||||
return gormigrate.
|
||||
@@ -867,3 +868,9 @@ func migrateAddAlbumEmbeddedCoverTrackID(tx *gorm.DB, _ MigrationContext) error
|
||||
func migrateAddTrackEmbeddedCover(tx *gorm.DB, _ MigrationContext) error {
|
||||
return tx.AutoMigrate(Track{}).Error
|
||||
}
|
||||
|
||||
func migrateAlbumAddIndexOnCreatedAt(tx *gorm.DB, _ MigrationContext) error {
|
||||
return tx.Exec(`
|
||||
CREATE INDEX idx_albums_created_at ON "albums" (created_at);
|
||||
`).Error
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
//go:build !nowasm
|
||||
|
||||
package deps
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
// Cgo-free Wasm database
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
|
||||
// Cgo-free Wasm tagger
|
||||
"go.senan.xyz/gonic/tags/taglib"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var TagReader = taglib.Reader{}
|
||||
|
||||
// DBDriverOptions returns SQLite DSN options for the ncruces driver
|
||||
func DBDriverOptions() url.Values {
|
||||
return url.Values{
|
||||
"_pragma": {
|
||||
"busy_timeout(30000)",
|
||||
"journal_mode(WAL)",
|
||||
"foreign_keys(ON)",
|
||||
},
|
||||
}
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
//go:build nowasm
|
||||
|
||||
package deps
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
// Cgo database
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
||||
// Cgo tagger
|
||||
"go.senan.xyz/gonic/tags/ffprobe"
|
||||
)
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var TagReader = ffprobe.Reader{}
|
||||
|
||||
// DSNOptions returns SQLite DSN options for the mattn driver
|
||||
func DBDriverOptions() url.Values {
|
||||
return url.Values{
|
||||
"_busy_timeout": {"30000"},
|
||||
"_journal_mode": {"WAL"},
|
||||
"_foreign_keys": {"true"},
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,13 @@ import (
|
||||
|
||||
var nonAlphaNumExpr = regexp.MustCompile("[^a-zA-Z0-9_.]+")
|
||||
|
||||
const maxFilenameLength = 200
|
||||
|
||||
func Safe(filename string) string {
|
||||
filename = nonAlphaNumExpr.ReplaceAllString(filename, "")
|
||||
return filename
|
||||
ext := filepath.Ext(filename)
|
||||
filename = filename[:min(maxFilenameLength, len(filename))-len(ext)]
|
||||
return filename + ext
|
||||
}
|
||||
|
||||
// try to find a unqiue file (or dir) name. incrementing like "example (1)"
|
||||
|
||||
@@ -57,3 +57,20 @@ func TestFirst(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, p("test"), r)
|
||||
}
|
||||
|
||||
func TestSafe(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
longName := "hi_00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||
result := Safe(longName)
|
||||
require.Equal(t, 200, len(result))
|
||||
require.Equal(t, longName[:200], result)
|
||||
|
||||
longNameWithExt := "hi_00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.mp3"
|
||||
result = Safe(longNameWithExt)
|
||||
require.Equal(t, 200, len(result))
|
||||
require.Equal(t, ".mp3", result[len(result)-4:])
|
||||
|
||||
require.Equal(t, "test.mp3", Safe("test.mp3"))
|
||||
require.Equal(t, "testing.mp3", Safe("test ing.mp3"))
|
||||
}
|
||||
@@ -24,17 +24,17 @@ require (
|
||||
github.com/microcosm-cc/bluemonday v1.0.27
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/mmcdole/gofeed v1.3.0
|
||||
github.com/ncruces/go-sqlite3 v0.29.1
|
||||
github.com/ncruces/go-sqlite3 v0.30.3
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/philippta/go-template v0.0.0-20220911145045-4556aca435e4
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be
|
||||
github.com/sentriz/gormstore v0.0.0-20220105134332-64e31f7f6981
|
||||
github.com/stretchr/testify v1.11.1
|
||||
go.senan.xyz/flagconf v0.1.9
|
||||
go.senan.xyz/taglib v0.10.1
|
||||
go.senan.xyz/wrtag v0.18.1-0.20250930121808-19bf03481e5e
|
||||
golang.org/x/net v0.44.0
|
||||
golang.org/x/sync v0.17.0
|
||||
go.senan.xyz/flagconf v0.1.10
|
||||
go.senan.xyz/taglib v0.11.1
|
||||
go.senan.xyz/wrtag v0.19.0
|
||||
golang.org/x/net v0.47.0
|
||||
golang.org/x/sync v0.18.0
|
||||
gopkg.in/gormigrate.v1 v1.6.0
|
||||
)
|
||||
|
||||
@@ -42,12 +42,12 @@ require (
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/PuerkitoBio/goquery v1.10.3 // indirect
|
||||
github.com/PuerkitoBio/goquery v1.11.0 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.22.1 // indirect
|
||||
github.com/go-openapi/swag/jsonname v0.25.1 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.22.3 // indirect
|
||||
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
|
||||
github.com/gorilla/context v1.1.2 // indirect
|
||||
github.com/gorilla/css v1.0.1 // indirect
|
||||
github.com/huandu/xstrings v1.5.0 // indirect
|
||||
@@ -63,11 +63,11 @@ require (
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/ncruces/julianday v1.0.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/tetratelabs/wazero v1.9.0 // indirect
|
||||
golang.org/x/crypto v0.42.0 // indirect
|
||||
golang.org/x/image v0.31.0 // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
github.com/tetratelabs/wazero v1.10.1 // indirect
|
||||
golang.org/x/crypto v0.45.0 // indirect
|
||||
golang.org/x/image v0.33.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/text v0.31.0 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
||||
@@ -8,8 +8,8 @@ github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF0
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo=
|
||||
github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y=
|
||||
github.com/PuerkitoBio/goquery v1.11.0 h1:jZ7pwMQXIITcUXNH83LLk+txlaEy6NVOfTuP43xxfqw=
|
||||
github.com/PuerkitoBio/goquery v1.11.0/go.mod h1:wQHgxUOU3JGuj3oD/QFfxUdlzW6xPHfqyHre6VMY4DQ=
|
||||
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74 h1:Kk6a4nehpJ3UuJRqlA3JxYxBZEqCeOmATOvrbT4p9RA=
|
||||
github.com/alexbrainman/sspi v0.0.0-20210105120005-909beea2cc74/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
|
||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
@@ -45,10 +45,12 @@ github.com/go-asn1-ber/asn1-ber v1.5.5 h1:MNHlNMBDgEKD4TcKr36vQN68BA00aDfjIt3/bD
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
||||
github.com/go-ldap/ldap/v3 v3.4.6 h1:ert95MdbiG7aWo/oPYp9btL3KJlMPKnP58r09rI8T+A=
|
||||
github.com/go-ldap/ldap/v3 v3.4.6/go.mod h1:IGMQANNtxpsOzj7uUAMjpGBaOVTC4DYyIy8VsTdxmtc=
|
||||
github.com/go-openapi/jsonpointer v0.22.1 h1:sHYI1He3b9NqJ4wXLoJDKmUmHkWy/L7rtEo92JUxBNk=
|
||||
github.com/go-openapi/jsonpointer v0.22.1/go.mod h1:pQT9OsLkfz1yWoMgYFy4x3U5GY5nUlsOn1qSBH5MkCM=
|
||||
github.com/go-openapi/swag/jsonname v0.25.1 h1:Sgx+qbwa4ej6AomWC6pEfXrA6uP2RkaNjA9BR8a1RJU=
|
||||
github.com/go-openapi/swag/jsonname v0.25.1/go.mod h1:71Tekow6UOLBD3wS7XhdT98g5J5GR13NOTQ9/6Q11Zo=
|
||||
github.com/go-openapi/jsonpointer v0.22.3 h1:dKMwfV4fmt6Ah90zloTbUKWMD+0he+12XYAsPotrkn8=
|
||||
github.com/go-openapi/jsonpointer v0.22.3/go.mod h1:0lBbqeRsQ5lIanv3LHZBrmRGHLHcQoOXQnf88fHlGWo=
|
||||
github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI=
|
||||
github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag=
|
||||
github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls=
|
||||
github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
@@ -97,10 +99,6 @@ github.com/josephburnett/jd v1.9.2 h1:ECJRRFXCCqbtidkAHckHGSZm/JIaAxS1gygHLF8MI5
|
||||
github.com/josephburnett/jd v1.9.2/go.mod h1:bImDr8QXpxMb3SD+w1cDRHp97xP6UwI88xUAuxwDQfM=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||
@@ -127,8 +125,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/ncruces/go-sqlite3 v0.29.1 h1:NIi8AISWBToRHyoz01FXiTNvU147Tqdibgj2tFzJCqM=
|
||||
github.com/ncruces/go-sqlite3 v0.29.1/go.mod h1:PpccBNNhvjwUOwDQEn2gXQPFPTWdlromj0+fSkd5KSg=
|
||||
github.com/ncruces/go-sqlite3 v0.30.3 h1:X/CgWW9GzmIAkEPrifhKqf0cC15DuOVxAJaHFTTAURQ=
|
||||
github.com/ncruces/go-sqlite3 v0.30.3/go.mod h1:AxKu9sRxkludimFocbktlY6LiYSkxiI5gTA8r+os/Nw=
|
||||
github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M=
|
||||
github.com/ncruces/julianday v1.0.0/go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
|
||||
@@ -153,15 +151,15 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
|
||||
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
|
||||
github.com/tetratelabs/wazero v1.10.1 h1:2DugeJf6VVk58KTPszlNfeeN8AhhpwcZqkJj2wwFuH8=
|
||||
github.com/tetratelabs/wazero v1.10.1/go.mod h1:DRm5twOQ5Gr1AoEdSi0CLjDQF1J9ZAuyqFIjl1KKfQU=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.senan.xyz/flagconf v0.1.9 h1:LBDmqiVFgijfqFXDzH97gPn0qDbg1Dq6/vxsxS/TzC4=
|
||||
go.senan.xyz/flagconf v0.1.9/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
|
||||
go.senan.xyz/taglib v0.10.1 h1:ez+lr7APh7BD3ft8PYgRM2Q8HKaiBkWZrZDHWwr4aDw=
|
||||
go.senan.xyz/taglib v0.10.1/go.mod h1:UMXxjvVuML3bZ63elOoUFtY2ZjwH88KB+DKWfF50ln8=
|
||||
go.senan.xyz/wrtag v0.18.1-0.20250930121808-19bf03481e5e h1:Q81nHdKVLExGp7+NosXA63dmPSwhijKZKzAhkC6gY4g=
|
||||
go.senan.xyz/wrtag v0.18.1-0.20250930121808-19bf03481e5e/go.mod h1:iBOnQIdvi55Y47SJxc4e5k1eu1bSeUwsq4hbFZOnXHU=
|
||||
go.senan.xyz/flagconf v0.1.10 h1:IGWaX9z4uh03xopYJSwpw1u0KrwRWs8vDmFjaULFH3U=
|
||||
go.senan.xyz/flagconf v0.1.10/go.mod h1:NqOFfSwJvNWXOTUabcRZ8mPK9+sJmhStJhqtEt74wNQ=
|
||||
go.senan.xyz/taglib v0.11.1 h1:S3mO5e3HRRG0Ehw1jLUodYbAJK8TtqdOoNgqkC0D3uU=
|
||||
go.senan.xyz/taglib v0.11.1/go.mod h1:qyTl978MnGeZ/ny4d/t0ErLXxysA+39X4+SNSCk56Zs=
|
||||
go.senan.xyz/wrtag v0.19.0 h1:/bWIbY5UVwmPPEn6FI3GQSEd5EZvOe1mECf2UriKYQU=
|
||||
go.senan.xyz/wrtag v0.19.0/go.mod h1:eaHgozP2mK2OG1AtEklet8uk9fX26w835BF4A+MhtEA=
|
||||
golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
@@ -171,11 +169,11 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.31.0 h1:mLChjE2MV6g1S7oqbXC0/UcKijjm5fnJLUYKIYrLESA=
|
||||
golang.org/x/image v0.31.0/go.mod h1:R9ec5Lcp96v9FTF+ajwaH3uGxPH4fKfHHAVbUILxghA=
|
||||
golang.org/x/image v0.33.0 h1:LXRZRnv1+zGd5XBUVRFmYEphyyKJjQjCRiOuAP3sZfQ=
|
||||
golang.org/x/image v0.33.0/go.mod h1:DD3OsTYT9chzuzTQt+zMcOlBHgfoKQb1gry8p76Y1sc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
@@ -195,8 +193,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -204,8 +202,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
||||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -220,8 +218,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
@@ -240,21 +238,20 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
|
||||
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
|
||||
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
||||
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/gormigrate.v1 v1.6.0 h1:XpYM6RHQPmzwY7Uyu+t+xxMXc86JYFJn4nEc9HzQjsI=
|
||||
gopkg.in/gormigrate.v1 v1.6.0/go.mod h1:Lf00lQrHqfSYWiTtPcyQabsDdM6ejZaMgV0OU6JMSlw=
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
|
||||
|
||||
@@ -12,9 +12,6 @@ import (
|
||||
"go.senan.xyz/gonic/lastfm"
|
||||
"go.senan.xyz/gonic/lastfm/mockclient"
|
||||
"go.senan.xyz/gonic/mockfs"
|
||||
|
||||
_ "github.com/ncruces/go-sqlite3/driver"
|
||||
_ "github.com/ncruces/go-sqlite3/embed"
|
||||
)
|
||||
|
||||
func TestInfoCache(t *testing.T) {
|
||||
|
||||
+17
-1
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"go.senan.xyz/gonic/db"
|
||||
"go.senan.xyz/gonic/deps"
|
||||
"go.senan.xyz/gonic/scanner"
|
||||
"go.senan.xyz/gonic/tags"
|
||||
"go.senan.xyz/wrtag/tags/normtag"
|
||||
@@ -35,7 +36,7 @@ func NewWithExcludePattern(tb testing.TB, excludePattern string) *MockFS {
|
||||
func newMockFS(tb testing.TB, dirs []string, excludePattern string) *MockFS {
|
||||
tb.Helper()
|
||||
|
||||
dbc, err := db.NewMock()
|
||||
dbc, err := db.NewMock(deps.DBDriverOptions())
|
||||
if err != nil {
|
||||
tb.Fatalf("create db: %v", err)
|
||||
}
|
||||
@@ -160,6 +161,21 @@ func (m *MockFS) RemoveAll(path string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockFS) Move(src, dest string) {
|
||||
srcAbs := filepath.Join(m.dir, src)
|
||||
destAbs := filepath.Join(m.dir, dest)
|
||||
if err := os.MkdirAll(filepath.Dir(destAbs), os.ModePerm); err != nil {
|
||||
m.t.Fatalf("mkdir: %v", err)
|
||||
}
|
||||
if err := os.Rename(srcAbs, destAbs); err != nil {
|
||||
m.t.Fatalf("rename: %v", err)
|
||||
}
|
||||
if info, ok := m.tagReader.paths[srcAbs]; ok {
|
||||
m.tagReader.paths[destAbs] = info
|
||||
delete(m.tagReader.paths, srcAbs)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MockFS) Symlink(src, dest string) {
|
||||
if err := os.MkdirAll(filepath.Dir(dest), os.ModePerm); err != nil {
|
||||
m.t.Fatalf("mkdir: %v", err)
|
||||
|
||||
+2
-2
@@ -513,7 +513,7 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
|
||||
return fmt.Errorf("get podcast episode filename: %w", err)
|
||||
}
|
||||
podcastEpisode.Filename = filename
|
||||
if err := p.db.Save(&podcastEpisode).Error; err != nil {
|
||||
if err := p.db.Save(podcastEpisode).Error; err != nil {
|
||||
return fmt.Errorf("save podcast episode: %w", err)
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Dir(filepath.Join(podcast.RootDir, podcastEpisode.Filename)), os.ModePerm); err != nil {
|
||||
@@ -528,7 +528,7 @@ func (p *Podcasts) doPodcastDownload(podcast *db.Podcast, podcastEpisode *db.Pod
|
||||
defer func() {
|
||||
if err != nil {
|
||||
podcastEpisode.Status = db.PodcastEpisodeStatusError
|
||||
_ = p.db.Save(&podcastEpisode).Error
|
||||
_ = p.db.Save(podcastEpisode).Error
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
+63
-4
@@ -104,6 +104,9 @@ func (s *Scanner) ScanAndClean(opts ScanOptions) (*State, error) {
|
||||
if err := s.cleanAlbums(st); err != nil {
|
||||
return nil, fmt.Errorf("clean albums: %w", err)
|
||||
}
|
||||
if err := s.cleanAlbumMetadata(); err != nil {
|
||||
return nil, fmt.Errorf("clean album metadata: %w", err)
|
||||
}
|
||||
if err := s.cleanArtists(st); err != nil {
|
||||
return nil, fmt.Errorf("clean artists: %w", err)
|
||||
}
|
||||
@@ -455,7 +458,7 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
|
||||
|
||||
// possible album level embedded covers come only from the first track
|
||||
if i == 0 {
|
||||
if err := populateAlbumEmbeddedCover(tx, album, track, trprops); err != nil {
|
||||
if err := populateAlbumEmbeddedCover(tx, s.scanEmbeddedCover, album, track, trprops); err != nil {
|
||||
return fmt.Errorf("populate embedded cover: %w", err)
|
||||
}
|
||||
}
|
||||
@@ -466,9 +469,9 @@ func (s *Scanner) populateTrackAndArtists(tx *db.DB, st *State, i int, album *db
|
||||
return nil
|
||||
}
|
||||
|
||||
func populateAlbumEmbeddedCover(tx *db.DB, album *db.Album, track *db.Track, trprops tags.Properties) error {
|
||||
func populateAlbumEmbeddedCover(tx *db.DB, scanEmbeddedCover bool, album *db.Album, track *db.Track, trprops tags.Properties) error {
|
||||
var trackID int
|
||||
if trprops.HasCover {
|
||||
if scanEmbeddedCover && trprops.HasCover {
|
||||
trackID = track.ID
|
||||
}
|
||||
var prevTrackID int
|
||||
@@ -497,7 +500,7 @@ func populateAlbum(tx *db.DB, album *db.Album, trags map[string][]string, modTim
|
||||
album.TagBrainzID = normtag.Get(trags, normtag.MusicBrainzReleaseID)
|
||||
album.TagYear = tags.MustYear(trags)
|
||||
album.TagCompilation = tags.ParseBool(normtag.Get(trags, normtag.Compilation))
|
||||
album.TagReleaseType = normtag.Get(trags, normtag.ReleaseType)
|
||||
album.TagReleaseType = strings.Join(normtag.Values(trags, normtag.ReleaseType), ", ")
|
||||
|
||||
album.ModifiedAt = modTime
|
||||
if album.CreatedAt.After(createTime) {
|
||||
@@ -697,6 +700,62 @@ func (s *Scanner) cleanAlbums(st *State) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Scanner) cleanAlbumMetadata() error {
|
||||
var numModified int
|
||||
|
||||
start := time.Now()
|
||||
defer func() { log.Printf("finished clean album metadata in %s, %d modified", durSince(start), numModified) }()
|
||||
|
||||
subTracks := s.db.Model(db.Track{}).Select("DISTINCT album_id").SubQuery()
|
||||
|
||||
var emptyAlbumIDs []int
|
||||
err := s.db.
|
||||
Model(db.Album{}).
|
||||
Where("id NOT IN ?", subTracks).
|
||||
Where("tag_title != '' OR tag_album_artist != ''").
|
||||
Pluck("id", &emptyAlbumIDs).
|
||||
Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("finding empty albums: %w", err)
|
||||
}
|
||||
if len(emptyAlbumIDs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
numModified = len(emptyAlbumIDs)
|
||||
|
||||
if err := s.db.Where("album_id IN (?)", emptyAlbumIDs).Delete(db.AlbumArtist{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.db.Where("album_id IN (?)", emptyAlbumIDs).Delete(db.AlbumGenre{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.db.Where("album_id IN (?)", emptyAlbumIDs).Delete(db.ArtistAppearances{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
q := s.db.
|
||||
Model(&db.Album{}).
|
||||
Where("id IN (?)", emptyAlbumIDs).
|
||||
Updates(map[string]any{
|
||||
"tag_title": "",
|
||||
"tag_title_u_dec": "",
|
||||
"tag_album_artist": "",
|
||||
"tag_year": 0,
|
||||
"tag_brainz_id": "",
|
||||
"tag_compilation": 0,
|
||||
"tag_release_type": "",
|
||||
"embedded_cover_track_id": nil,
|
||||
})
|
||||
if err := q.Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
numModified = int(q.RowsAffected)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Scanner) cleanArtists(st *State) error {
|
||||
start := time.Now()
|
||||
defer func() { log.Printf("finished clean artists in %s, %d removed", durSince(start), st.ArtistsMissing()) }()
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
package scanner_test
|
||||
|
||||
import (
|
||||
@@ -9,7 +6,6 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.senan.xyz/gonic/mockfs"
|
||||
)
|
||||
|
||||
+33
-1
@@ -10,10 +10,11 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
_ "go.senan.xyz/gonic/deps"
|
||||
|
||||
"go.senan.xyz/gonic/db"
|
||||
"go.senan.xyz/gonic/mockfs"
|
||||
"go.senan.xyz/gonic/scanner"
|
||||
@@ -123,6 +124,37 @@ func TestCoverBeforeTracks(t *testing.T) {
|
||||
assert.Equal(t, 3, len(tracks)) // album has tracks
|
||||
}
|
||||
|
||||
// https://github.com/sentriz/gonic/issues/638
|
||||
func TestAlbumArtistsClearedWhenFolderLosesTracks(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mockfs.New(t)
|
||||
|
||||
loosePath := "artist-0/fusion.flac"
|
||||
nestedPath := "artist-0/album-0/track-0.flac"
|
||||
|
||||
m.AddTrack(loosePath)
|
||||
m.SetTags(loosePath, func(tags *mockfs.TagInfo) {
|
||||
normtag.Set(tags.Tags, normtag.Artist, "artist-0")
|
||||
normtag.Set(tags.Tags, normtag.AlbumArtist, "artist-0")
|
||||
normtag.Set(tags.Tags, normtag.Album, "Fusion Firespace")
|
||||
normtag.Set(tags.Tags, normtag.Title, "Fusion Firespace")
|
||||
})
|
||||
|
||||
m.ScanAndClean()
|
||||
|
||||
var albumArtistCount int
|
||||
require.NoError(t, m.DB().Model(db.AlbumArtist{}).Count(&albumArtistCount).Error)
|
||||
require.Equal(t, 1, albumArtistCount)
|
||||
|
||||
m.Move(loosePath, nestedPath)
|
||||
|
||||
m.ScanAndClean()
|
||||
|
||||
var postAlbumArtistCount int
|
||||
require.NoError(t, m.DB().Model(db.AlbumArtist{}).Count(&postAlbumArtistCount).Error)
|
||||
require.Equal(t, 1, postAlbumArtistCount)
|
||||
}
|
||||
|
||||
func TestUpdatedTags(t *testing.T) {
|
||||
t.Parallel()
|
||||
m := mockfs.New(t)
|
||||
|
||||
@@ -18,6 +18,8 @@ import (
|
||||
jd "github.com/josephburnett/jd/lib"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
_ "go.senan.xyz/gonic/deps"
|
||||
|
||||
"go.senan.xyz/gonic"
|
||||
"go.senan.xyz/gonic/db"
|
||||
"go.senan.xyz/gonic/mockfs"
|
||||
|
||||
@@ -3,8 +3,6 @@ package ctrlsubsonic
|
||||
import (
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
)
|
||||
|
||||
func TestGetIndexes(t *testing.T) {
|
||||
|
||||
@@ -44,10 +44,6 @@ func (c *Controller) ServeGetNewestPodcasts(r *http.Request) *spec.Response {
|
||||
}
|
||||
|
||||
func (c *Controller) ServeDownloadPodcastEpisode(r *http.Request) *spec.Response {
|
||||
user := r.Context().Value(CtxUser).(*db.User)
|
||||
if !user.IsAdmin {
|
||||
return spec.NewError(50, "user not admin")
|
||||
}
|
||||
params := r.Context().Value(CtxParams).(params.Params)
|
||||
id, err := params.GetID("id")
|
||||
if err != nil || id.Type != specid.PodcastEpisode {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -33,7 +34,18 @@ import (
|
||||
|
||||
const (
|
||||
coverDefaultSize = 600
|
||||
coverCacheFormat = "png"
|
||||
)
|
||||
|
||||
var (
|
||||
//nolint:gochecknoglobals
|
||||
// after the image is decoded with image.Decode, we use the "format" param as the extension
|
||||
coverCacheFormats = []string{
|
||||
"jpeg", // from image.RegisterFormat("jpeg") @ image/jpeg/reader.go
|
||||
"png", // from image.RegisterFormat("png") @ image/png/reader.go
|
||||
"gif", // from image.RegisterFormat("gif") @ image/gif/reader.go
|
||||
"bmp", // from image.RegisterFormat("bmp") @ golang.org/x/image/bmp/reader.go
|
||||
"tiff", // from image.RegisterFormat("tiff") @ golang.org/x/image/tiff/reader.go
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *spec.Response {
|
||||
@@ -42,35 +54,77 @@ func (c *Controller) ServeGetCoverArt(w http.ResponseWriter, r *http.Request) *s
|
||||
if err != nil {
|
||||
return spec.NewError(10, "please provide an `id` parameter")
|
||||
}
|
||||
size := params.GetOrInt("size", coverDefaultSize)
|
||||
cachePath := filepath.Join(
|
||||
c.cacheCoverPath,
|
||||
fmt.Sprintf("%s-%d.%s", id.String(), size, coverCacheFormat),
|
||||
)
|
||||
_, err = os.Stat(cachePath)
|
||||
switch {
|
||||
case os.IsNotExist(err):
|
||||
reader, err := coverFor(c.dbc, c.artistInfoCache, c.tagReader, id)
|
||||
if err != nil {
|
||||
return spec.NewError(10, "couldn't find cover %q: %v", id, err)
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
if err := coverScaleAndSave(reader, cachePath, size); err != nil {
|
||||
log.Printf("error scaling cover: %v", err)
|
||||
return nil
|
||||
}
|
||||
case err != nil:
|
||||
log.Printf("error stating %q: %v", cachePath, err)
|
||||
size := params.GetOrInt("size", coverDefaultSize)
|
||||
if size <= 0 {
|
||||
return spec.NewError(0, "invalid size")
|
||||
}
|
||||
|
||||
// cached cover could exist for any supported format
|
||||
cachePath, err := findCachedCover(c.cacheCoverPath, id.String(), size)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
log.Printf("error checking cache: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
w.Header().Set("Cache-Control", "public, max-age=1209600")
|
||||
http.ServeFile(w, r, cachePath)
|
||||
serve := func(p string) {
|
||||
w.Header().Set("Cache-Control", "public, max-age=1209600")
|
||||
http.ServeFile(w, r, p)
|
||||
}
|
||||
|
||||
if cachePath != "" {
|
||||
serve(cachePath)
|
||||
return nil
|
||||
}
|
||||
|
||||
reader, err := coverFor(c.dbc, c.artistInfoCache, c.tagReader, id)
|
||||
if err != nil {
|
||||
return spec.NewError(10, "couldn't find cover %q: %v", id, err)
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
img, format, err := image.Decode(reader)
|
||||
if err != nil {
|
||||
return spec.NewError(0, "decode for cover %q: %v", id, err)
|
||||
}
|
||||
|
||||
// don't upscale
|
||||
minSize := min(size, max(img.Bounds().Dx(), img.Bounds().Dy()))
|
||||
|
||||
cachePath = filepath.Join(c.cacheCoverPath, coverCacheFilename(id.String(), minSize, format))
|
||||
|
||||
if minSize != size {
|
||||
// we down sized, check cache again
|
||||
if _, err := os.Stat(cachePath); err == nil {
|
||||
serve(cachePath)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
resized := imaging.Fit(img, minSize, minSize, imaging.Lanczos)
|
||||
|
||||
if err := imaging.Save(resized, cachePath); err != nil {
|
||||
return spec.NewError(10, "saving cover %q: %v", id, err)
|
||||
}
|
||||
|
||||
serve(cachePath)
|
||||
return nil
|
||||
}
|
||||
|
||||
func coverCacheFilename(idStr string, size int, format string) string {
|
||||
return fmt.Sprintf("%s-%d.%s", idStr, size, format)
|
||||
}
|
||||
|
||||
func findCachedCover(cacheDir, idStr string, size int) (string, error) {
|
||||
for _, format := range coverCacheFormats {
|
||||
cachePath := filepath.Join(cacheDir, coverCacheFilename(idStr, size, format))
|
||||
if _, err := os.Stat(cachePath); err == nil {
|
||||
return cachePath, nil
|
||||
}
|
||||
}
|
||||
return "", os.ErrNotExist
|
||||
}
|
||||
|
||||
var (
|
||||
errCoverNotFound = errors.New("could not find a cover with that id")
|
||||
errCoverEmpty = errors.New("no cover found")
|
||||
@@ -176,21 +230,6 @@ func coverForTrack(dbc *db.DB, tagReader tags.Reader, id int) (io.ReadCloser, er
|
||||
return io.NopCloser(bytes.NewReader(cover)), nil
|
||||
}
|
||||
|
||||
func coverScaleAndSave(reader io.Reader, cachePath string, size int) error {
|
||||
src, err := imaging.Decode(reader)
|
||||
if err != nil {
|
||||
return fmt.Errorf("resizing: %w", err)
|
||||
}
|
||||
|
||||
// don't upscale images
|
||||
width := min(size, src.Bounds().Dx())
|
||||
|
||||
if err := imaging.Save(imaging.Resize(src, width, 0, imaging.Lanczos), cachePath); err != nil {
|
||||
return fmt.Errorf("caching %q: %w", cachePath, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.Response {
|
||||
params := r.Context().Value(CtxParams).(params.Params)
|
||||
user := r.Context().Value(CtxUser).(*db.User)
|
||||
|
||||
@@ -15,7 +15,7 @@ type Reader struct{}
|
||||
|
||||
func (Reader) CanRead(absPath string) bool {
|
||||
switch ext := strings.ToLower(filepath.Ext(absPath)); ext {
|
||||
case ".mp3", ".flac", ".aac", ".m4a", ".m4b", ".ogg", ".opus", ".wma", ".wav", ".wv":
|
||||
case ".mp3", ".flac", ".aac", ".m4a", ".m4b", ".ogg", ".opus", ".wma", ".wav", ".wv", ".ape":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
0.18.0
|
||||
0.19.0
|
||||
Reference in New Issue
Block a user