Skip to content

Commit 3f5cd76

Browse files
committed
0.13.4
1 parent 5b8513e commit 3f5cd76

5 files changed

Lines changed: 18 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
44

55
**Warning:** Features marked as *alpha* may change or be removed in a future release without notice. Use with caution.
66

7+
## [0.13.4] - 2026-03-09
8+
9+
### Changed
10+
11+
- The mimetype for OPUS is now the modern `audio/opus`, to align with the other toolkits
12+
- The mimetype string matcher now removes spaces, so that `audio/ogg; codecs=opus` and `audio/ogg;codecs=opus` are the same when searching for a match
13+
14+
### Fixed
15+
16+
- Fixed race condition causing local file reads to fail due to early closure
17+
718
## [0.13.3] - 2026-02-27
819

920
### Fixed

pkg/fetcher/fetcher_file.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ func (r *FileResource) open() (*os.File, *ResourceError) {
181181

182182
// Read implements Resource
183183
func (r *FileResource) Read(ctx context.Context, start int64, end int64) ([]byte, *ResourceError) {
184+
defer runtime.KeepAlive(r)
184185
if end < start {
185186
return nil, RangeNotSatisfiable(errors.New("end of range smaller than start"))
186187
}
@@ -214,6 +215,7 @@ func (r *FileResource) Read(ctx context.Context, start int64, end int64) ([]byte
214215

215216
// Stream implements Resource
216217
func (r *FileResource) Stream(ctx context.Context, w io.Writer, start int64, end int64) (int64, *ResourceError) {
218+
defer runtime.KeepAlive(r)
217219
if end < start {
218220
err := RangeNotSatisfiable(errors.New("end of range smaller than start"))
219221
return -1, err
@@ -245,6 +247,7 @@ func (r *FileResource) Stream(ctx context.Context, w io.Writer, start int64, end
245247

246248
// Length implements Resource
247249
func (r *FileResource) Length(ctx context.Context) (int64, *ResourceError) {
250+
defer runtime.KeepAlive(r)
248251
f, ex := r.open()
249252
if ex != nil {
250253
return 0, ex

pkg/mediatype/mediatype.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ func New(str string, name string, extension string) (mt MediaType, err error) {
107107
// Create a new MediaType solely from a mime string.
108108
// When an error is returned, do not use the resulting MediaType, as it will be incomplete/invalid
109109
func NewOfString(str string) (MediaType, error) {
110-
if knownMatch, ok := knownMatches[str]; ok {
110+
noSpaceStr := strings.ReplaceAll(str, " ", "")
111+
if knownMatch, ok := knownMatches[noSpaceStr]; ok {
111112
// The string was recognized as a known mimetype.
112113
// This not only shortcuts building of the MediaType,
113114
// but also ensures that the resulting MediaType is identical

pkg/mediatype/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var OPDS2, _ = New("application/opds+json", "OPDS 2 Catalog", "")
3434
var OPDS2Publication, _ = New("application/opds-publication+json", "OPDS 2 Publication", "")
3535
var OPDSAuthentication, _ = New("application/opds-authentication+json", "OPDS 2 Authentication Document", "")
3636
var OPF, _ = New("application/oebps-package+xml", "EPUB Package Document", "opf")
37-
var OPUS, _ = New("audio/ogg; codecs=opus", "OPUS Audio", "opus")
37+
var OPUS, _ = New("audio/opus", "OPUS Audio", "opus")
3838
var OTF, _ = New("font/otf", "OpenType Font", "otf")
3939
var PDF, _ = New("application/pdf", "PDF", "pdf")
4040
var PNG, _ = New("image/png", "Portable Network Graphics", "png")

pkg/mediatype/types_matcher.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var knownMatches = map[string]*MediaType{
3939
"application/opds-authentication+json": &OPDSAuthentication,
4040
"application/oebps-package+xml": &OPF,
4141
"audio/opus": &OPUS,
42+
"audio/ogg;codecs=opus": &OPUS,
4243
"font/otf": &OTF,
4344
"application/pdf": &PDF,
4445
"image/png": &PNG,

0 commit comments

Comments
 (0)