Use `await using` in async methods

pull/1658/head
Bogdan 2 years ago
parent d38f2614d3
commit 34fbb3e135

@ -322,7 +322,7 @@ namespace NzbDrone.Common.Http
_logger.Debug("Downloading [{0}] to [{1}]", url, fileName); _logger.Debug("Downloading [{0}] to [{1}]", url, fileName);
var stopWatch = Stopwatch.StartNew(); var stopWatch = Stopwatch.StartNew();
using (var fileStream = new FileStream(fileNamePart, FileMode.Create, FileAccess.ReadWrite)) await using (var fileStream = new FileStream(fileNamePart, FileMode.Create, FileAccess.ReadWrite))
{ {
var request = new HttpRequest(url); var request = new HttpRequest(url);
request.AllowAutoRedirect = true; request.AllowAutoRedirect = true;

@ -179,21 +179,12 @@ namespace NzbDrone.Core.Localization
return; return;
} }
using (var fs = File.OpenRead(resourcePath)) await using var fs = File.OpenRead(resourcePath);
var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(fs);
foreach (var key in dict.Keys)
{ {
if (fs != null) dictionary[key] = dict[key];
{
var dict = await JsonSerializer.DeserializeAsync<Dictionary<string, string>>(fs);
foreach (var key in dict.Keys)
{
dictionary[key] = dict[key];
}
}
else
{
_logger.Error("Missing translation/culture resource: {0}", resourcePath);
}
} }
} }

Loading…
Cancel
Save