Browse Source

Code revie

David 4 years ago
parent
commit
21fd124bca

+ 1 - 1
Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs

@@ -94,7 +94,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
             _logFileStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
 
             await JsonSerializer.SerializeAsync(_logFileStream, mediaSource, _jsonOptions, cancellationToken).ConfigureAwait(false);
-            await _logFileStream.WriteAsync(Encoding.UTF8.GetBytes(Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine), cancellationToken);
+            await _logFileStream.WriteAsync(Encoding.UTF8.GetBytes(Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine), cancellationToken).ConfigureAwait(false);
 
             _process = new Process
             {

+ 3 - 3
Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs

@@ -151,7 +151,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
                                 }
                                 else
                                 {
-                                    _logger.LogDebug("Scheduled Task history file {path} is empty. Skipping deserialization.", path);
+                                    _logger.LogDebug("Scheduled Task history file {Path} is empty. Skipping deserialization.", path);
                                 }
                             }
                             catch (Exception ex)
@@ -577,8 +577,8 @@ namespace Emby.Server.Implementations.ScheduledTasks
 
             Directory.CreateDirectory(Path.GetDirectoryName(path));
 
-            using FileStream stream = File.OpenWrite(path);
-            JsonSerializer.SerializeAsync(stream, triggers, _jsonOptions);
+            var json = JsonSerializer.Serialize(triggers, _jsonOptions);
+            File.WriteAllText(path, json);
         }
 
         /// <summary>

+ 2 - 2
MediaBrowser.Providers/Plugins/Omdb/OmdbProvider.cs

@@ -351,9 +351,9 @@ namespace MediaBrowser.Providers.Plugins.Omdb
         public async Task<T> GetDeserializedOmdbResponse<T>(HttpClient httpClient, string url, CancellationToken cancellationToken)
         {
             using var response = await GetOmdbResponse(httpClient, url, cancellationToken).ConfigureAwait(false);
-            var content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+            await using Stream content = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
 
-            return JsonSerializer.Deserialize<T>(content, _jsonOptions);
+            return await JsonSerializer.DeserializeAsync<T>(content, _jsonOptions, cancellationToken).ConfigureAwait(false);
         }
 
         public static Task<HttpResponseMessage> GetOmdbResponse(HttpClient httpClient, string url, CancellationToken cancellationToken)