Selaa lähdekoodia

Merge pull request #10881 from TelepathicWalrus/fix-livetv-delay

Fix long live tv load times, Fixes #10761
Bond-009 1 vuosi sitten
vanhempi
sitoutus
a2fdec4363
1 muutettua tiedostoa jossa 10 lisäystä ja 7 poistoa
  1. 10 7
      Emby.Server.Implementations/Library/LiveStreamHelper.cs

+ 10 - 7
Emby.Server.Implementations/Library/LiveStreamHelper.cs

@@ -48,20 +48,23 @@ namespace Emby.Server.Implementations.Library
 
             if (!string.IsNullOrEmpty(cacheKey))
             {
-                FileStream jsonStream = AsyncFile.OpenRead(cacheFilePath);
                 try
                 {
-                    mediaInfo = await JsonSerializer.DeserializeAsync<MediaInfo>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
+                    FileStream jsonStream = AsyncFile.OpenRead(cacheFilePath);
 
-                    // _logger.LogDebug("Found cached media info");
+                    await using (jsonStream.ConfigureAwait(false))
+                    {
+                        mediaInfo = await JsonSerializer.DeserializeAsync<MediaInfo>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
+                        // _logger.LogDebug("Found cached media info");
+                    }
                 }
-                catch (Exception ex)
+                catch (IOException ex)
                 {
-                    _logger.LogError(ex, "Error deserializing mediainfo cache");
+                    _logger.LogDebug(ex, "Could not open cached media info");
                 }
-                finally
+                catch (Exception ex)
                 {
-                    await jsonStream.DisposeAsync().ConfigureAwait(false);
+                    _logger.LogError(ex, "Error opening cached media info");
                 }
             }