fix(scanner): pass filename hint to gotaglib's OpenStream for format detection (#5012)
* fix: split reflex -R flags to preserve directory exclusion optimization Combining the _test.go exclusion pattern (which uses $) into the same -R regex as the directory prefixes (^ui, ^data, ^db/migrations) disabled reflex's ExcludePrefix optimization. Reflex disables prefix-based directory skipping when the regex AST contains $, \z, or \b operators, causing it to traverse into ui/node_modules and hit "too many open files". Splitting into two separate -R flags fixes this: the directory prefix regex remains $-free so ExcludePrefix works, while the _test.go pattern gets its own flag where the $ anchor doesn't affect directory skipping. * fix(gotaglib): pass filename hint to OpenStream for format detection OpenStream relies on content-sniffing when no filename is provided, which fails for some files (e.g. OPUS). Pass the filename via the new WithFilename option so TagLib can use the file extension as a hint. Also adds an OPUS test fixture and test entry. Relates to https://github.com/navidrome/navidrome/issues/4604#issuecomment-3868569113, #4998, #5010
This commit is contained in:
@@ -119,7 +119,12 @@ func (e extractor) openFile(filePath string) (f *taglib.File, closeFunc func(),
|
||||
file.Close()
|
||||
return nil, nil, errors.New("file is not seekable")
|
||||
}
|
||||
f, err = taglib.OpenStream(rs, taglib.WithReadStyle(taglib.ReadStyleFast))
|
||||
// WithFilename provides a format detection hint via the file extension,
|
||||
// since OpenStream alone relies on content-sniffing which fails for some files.
|
||||
f, err = taglib.OpenStream(rs,
|
||||
taglib.WithReadStyle(taglib.ReadStyleFast),
|
||||
taglib.WithFilename(filePath),
|
||||
)
|
||||
if err != nil {
|
||||
file.Close()
|
||||
return nil, nil, err
|
||||
|
||||
Reference in New Issue
Block a user