Browse Source

Fix More Live TV Warnings (#10818)

* Fix CA1819 in LiveTvManager

* Call ConfigureAwait in ChannelManager
Patrick Barron 1 năm trước cách đây
mục cha
commit
82f93afa22

+ 24 - 11
Emby.Server.Implementations/Channels/ChannelManager.cs

@@ -812,11 +812,16 @@ namespace Emby.Server.Implementations.Channels
             {
                 if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
                 {
-                    await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
-                    var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
-                    if (cachedResult is not null)
+                    var jsonStream = AsyncFile.OpenRead(cachePath);
+                    await using (jsonStream.ConfigureAwait(false))
                     {
-                        return null;
+                        var cachedResult = await JsonSerializer
+                            .DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken)
+                            .ConfigureAwait(false);
+                        if (cachedResult is not null)
+                        {
+                            return null;
+                        }
                     }
                 }
             }
@@ -835,11 +840,16 @@ namespace Emby.Server.Implementations.Channels
                 {
                     if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow)
                     {
-                        await using FileStream jsonStream = AsyncFile.OpenRead(cachePath);
-                        var cachedResult = await JsonSerializer.DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken).ConfigureAwait(false);
-                        if (cachedResult is not null)
+                        var jsonStream = AsyncFile.OpenRead(cachePath);
+                        await using (jsonStream.ConfigureAwait(false))
                         {
-                            return null;
+                            var cachedResult = await JsonSerializer
+                                .DeserializeAsync<ChannelItemResult>(jsonStream, _jsonOptions, cancellationToken)
+                                .ConfigureAwait(false);
+                            if (cachedResult is not null)
+                            {
+                                return null;
+                            }
                         }
                     }
                 }
@@ -867,7 +877,7 @@ namespace Emby.Server.Implementations.Channels
                     throw new InvalidOperationException("Channel returned a null result from GetChannelItems");
                 }
 
-                await CacheResponse(result, cachePath);
+                await CacheResponse(result, cachePath).ConfigureAwait(false);
 
                 return result;
             }
@@ -883,8 +893,11 @@ namespace Emby.Server.Implementations.Channels
             {
                 Directory.CreateDirectory(Path.GetDirectoryName(path));
 
-                await using FileStream createStream = File.Create(path);
-                await JsonSerializer.SerializeAsync(createStream, result, _jsonOptions).ConfigureAwait(false);
+                var createStream = File.Create(path);
+                await using (createStream.ConfigureAwait(false))
+                {
+                    await JsonSerializer.SerializeAsync(createStream, result, _jsonOptions).ConfigureAwait(false);
+                }
             }
             catch (Exception ex)
             {

+ 2 - 2
Emby.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -105,9 +105,9 @@ namespace Emby.Server.Implementations.LiveTv
         /// <value>The services.</value>
         public IReadOnlyList<ILiveTvService> Services => _services;
 
-        public ITunerHost[] TunerHosts => _tunerHosts;
+        public IReadOnlyList<ITunerHost> TunerHosts => _tunerHosts;
 
-        public IListingsProvider[] ListingProviders => _listingProviders;
+        public IReadOnlyList<IListingsProvider> ListingProviders => _listingProviders;
 
         private LiveTvOptions GetConfiguration()
         {

+ 1 - 1
MediaBrowser.Controller/LiveTv/ILiveTvManager.cs

@@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.LiveTv
         /// <value>The services.</value>
         IReadOnlyList<ILiveTvService> Services { get; }
 
-        IListingsProvider[] ListingProviders { get; }
+        IReadOnlyList<IListingsProvider> ListingProviders { get; }
 
         /// <summary>
         /// Gets the new timer defaults asynchronous.