From 4836d1674bdc076431c0ac18171c1b97c7e254ce Mon Sep 17 00:00:00 2001 From: Ian Walton Date: Mon, 23 Mar 2020 12:39:12 -0400 Subject: [PATCH] Don't return closed stream for subtitles. (jellyfin/jellyfin#2650) --- MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 72db569744..6284e0fd9e 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -183,9 +183,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles private async Task GetSubtitleStream(string path, MediaProtocol protocol, bool requiresCharset, CancellationToken cancellationToken) { - using (var stream = await GetStream(path, protocol, cancellationToken).ConfigureAwait(false)) + if (requiresCharset) { - if (requiresCharset) + using (var stream = await GetStream(path, protocol, cancellationToken).ConfigureAwait(false)) { var result = CharsetDetector.DetectFromStream(stream).Detected; stream.Position = 0; @@ -200,9 +200,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles return new MemoryStream(Encoding.UTF8.GetBytes(text)); } } - - return stream; } + + return File.OpenRead(path); } private async Task GetReadableFile(