fix(server): failed transcoded files should not be cached (#4124)

* Close stream on caching errors

* fix(test): replace errPartialReader with errFakeReader to fix lint error

Signed-off-by: Deluan <deluan@navidrome.org>

* fix(test): update error assertion to check for substring in closed file error

Signed-off-by: Deluan <deluan@navidrome.org>

---------

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan Quintão
2025-05-26 20:30:26 -04:00
committed by GitHub
parent 030710afa9
commit 9dd5a8c334
2 changed files with 18 additions and 8 deletions
+1
View File
@@ -174,6 +174,7 @@ func (fc *fileCache) Get(ctx context.Context, arg Item) (*CachedStream, error) {
go func() {
if err := copyAndClose(w, reader); err != nil {
log.Debug(ctx, "Error storing file in cache", "cache", fc.name, "key", key, err)
_ = r.Close()
_ = fc.invalidate(ctx, key)
} else {
log.Trace(ctx, "File successfully stored in cache", "cache", fc.name, "key", key)