From da969dec5cb4f7682acc1965dc8ddf77be8c129f Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Tue, 20 Feb 2024 15:42:49 +0900 Subject: [PATCH] DAssetM cleanup --- Dalamud/Storage/Assets/DalamudAssetManager.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Dalamud/Storage/Assets/DalamudAssetManager.cs b/Dalamud/Storage/Assets/DalamudAssetManager.cs index 7edb1c61d..69c7c32e8 100644 --- a/Dalamud/Storage/Assets/DalamudAssetManager.cs +++ b/Dalamud/Storage/Assets/DalamudAssetManager.cs @@ -194,12 +194,14 @@ internal sealed class DalamudAssetManager : IServiceType, IDisposable, IDalamudA try { - await using var tempPathStream = File.Open(tempPath, FileMode.Create, FileAccess.Write); - await url.DownloadAsync( - this.httpClient.SharedHttpClient, - tempPathStream, - this.cancellationTokenSource.Token); - tempPathStream.Dispose(); + await using (var tempPathStream = File.Open(tempPath, FileMode.Create, FileAccess.Write)) + { + await url.DownloadAsync( + this.httpClient.SharedHttpClient, + tempPathStream, + this.cancellationTokenSource.Token); + } + for (var j = RenameAttemptCount; ; j--) { try @@ -265,7 +267,7 @@ internal sealed class DalamudAssetManager : IServiceType, IDisposable, IDalamudA /// [Pure] public IDalamudTextureWrap GetDalamudTextureWrap(DalamudAsset asset) => - ExtractResult(this.GetDalamudTextureWrapAsync(asset)); + this.GetDalamudTextureWrapAsync(asset).Result; /// [Pure] @@ -332,8 +334,6 @@ internal sealed class DalamudAssetManager : IServiceType, IDisposable, IDalamudA } } - private static T ExtractResult(Task t) => t.IsCompleted ? t.Result : t.GetAwaiter().GetResult(); - private Task TransformImmediate(Task task, Func transformer) { if (task.IsCompletedSuccessfully)