Răsfoiți Sursa

change to using declaration

crobibero 4 ani în urmă
părinte
comite
8d592777c4
1 a modificat fișierele cu 8 adăugiri și 9 ștergeri
  1. 8 9
      Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs

+ 8 - 9
Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs

@@ -70,18 +70,17 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
 
 
             Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
             Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
 
 
-            using (var output = new FileStream(targetFile, FileMode.Create, FileAccess.Write, FileShare.Read))
-            {
-                onStarted();
+            await using var output = new FileStream(targetFile, FileMode.Create, FileAccess.Write, FileShare.Read);
 
 
-                _logger.LogInformation("Copying recording stream to file {0}", targetFile);
+            onStarted();
 
 
-                // The media source if infinite so we need to handle stopping ourselves
-                var durationToken = new CancellationTokenSource(duration);
-                cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
+            _logger.LogInformation("Copying recording stream to file {0}", targetFile);
 
 
-                await _streamHelper.CopyUntilCancelled(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), output, 81920, cancellationToken).ConfigureAwait(false);
-            }
+            // The media source if infinite so we need to handle stopping ourselves
+            var durationToken = new CancellationTokenSource(duration);
+            cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
+
+            await _streamHelper.CopyUntilCancelled(await response.Content.ReadAsStreamAsync().ConfigureAwait(false), output, 81920, cancellationToken).ConfigureAwait(false);
 
 
             _logger.LogInformation("Recording completed to file {0}", targetFile);
             _logger.LogInformation("Recording completed to file {0}", targetFile);
         }
         }