diff --git a/CollapseLauncher/Classes/Helper/Image/ImageLoaderHelper.cs b/CollapseLauncher/Classes/Helper/Image/ImageLoaderHelper.cs index 80c2571f2..1f8b01f2c 100644 --- a/CollapseLauncher/Classes/Helper/Image/ImageLoaderHelper.cs +++ b/CollapseLauncher/Classes/Helper/Image/ImageLoaderHelper.cs @@ -490,38 +490,36 @@ public static async ValueTask TryDownloadToCompleteness(string url, FileInfo fil Logger.LogWriteLine($"Start downloading resource from: {url}", LogType.Default, true); + if (fileInfo.Exists) + fileInfo.Delete(); // Try to get the remote stream and download the file - await using Stream netStream = await FallbackCDNUtil.GetHttpStreamFromResponse(url, token); - await using (Stream outStream = fileInfoTemp.Open(new FileStreamOptions() + await using (Stream netStream = await FallbackCDNUtil.GetHttpStreamFromResponse(url, token)) { - Access = FileAccess.Write, - Mode = FileMode.Create, - Share = FileShare.ReadWrite, - Options = FileOptions.Asynchronous - })) - { - // Get the file length - fileLength = netStream.Length; - - // Create the prop file for download completeness checking - string outputParentPath = Path.GetDirectoryName(fileInfoTemp.FullName); - string outputFilename = Path.GetFileName(fileInfoTemp.FullName); - if (outputParentPath != null) + await using (Stream outStream = fileInfoTemp.Create()) { - string propFilePath = Path.Combine(outputParentPath, $"{outputFilename}#{netStream.Length}"); - await File.Create(propFilePath).DisposeAsync(); + // Get the file length + fileLength = netStream.Length; + + // Create the prop file for download completeness checking + string outputParentPath = Path.GetDirectoryName(fileInfoTemp.FullName); + string outputFilename = Path.GetFileName(fileInfoTemp.FullName); + if (outputParentPath != null) + { + string propFilePath = Path.Combine(outputParentPath, $"{outputFilename}#{netStream.Length}"); + await File.Create(propFilePath).DisposeAsync(); + } + + // Copy (and download) the remote streams to local + int read; + while ((read = await netStream.ReadAsync(buffer, token)) > 0) + await outStream.WriteAsync(buffer, 0, read, token); } - - // Copy (and download) the remote streams to local - int read; - while ((read = await netStream.ReadAsync(buffer, token)) > 0) - await outStream.WriteAsync(buffer, 0, read, token); } - // If the file has already been downloaded, then move to its original filename - if (fileInfoTemp.Exists) - fileInfoTemp.MoveTo(fileInfo.FullName, true); + // Move to its original filename + fileInfoTemp.Refresh(); + fileInfoTemp.MoveTo(fileInfo.FullName, true); Logger.LogWriteLine($"Resource download from: {url} has been completed and stored locally into:" + $"\"{fileInfo.FullName}\" with size: {ConverterTool.SummarizeSizeSimple(fileLength)} ({fileLength} bytes)", LogType.Default, true); diff --git a/CollapseLauncher/Classes/Helper/StreamUtility.cs b/CollapseLauncher/Classes/Helper/StreamUtility.cs index 91c943d04..add6a9cc0 100644 --- a/CollapseLauncher/Classes/Helper/StreamUtility.cs +++ b/CollapseLauncher/Classes/Helper/StreamUtility.cs @@ -17,27 +17,21 @@ internal static class StreamUtility { Mode = FileMode.Open, Access = FileAccess.Read, - Share = FileShare.Read, - BufferSize = DefaultBufferSize, - Options = FileOptions.Asynchronous | FileOptions.RandomAccess + Share = FileShare.Read }; internal static readonly FileStreamOptions FileStreamCreateWriteOpt = new FileStreamOptions { Mode = FileMode.Create, Access = FileAccess.Write, - Share = FileShare.Write, - BufferSize = DefaultBufferSize, - Options = FileOptions.Asynchronous | FileOptions.RandomAccess + Share = FileShare.Write }; internal static readonly FileStreamOptions FileStreamCreateReadWriteOpt = new FileStreamOptions { Mode = FileMode.Create, Access = FileAccess.ReadWrite, - Share = FileShare.ReadWrite, - BufferSize = DefaultBufferSize, - Options = FileOptions.Asynchronous | FileOptions.RandomAccess + Share = FileShare.ReadWrite }; /* diff --git a/CollapseLauncher/Classes/ShortcutCreator/SteamShortcut.cs b/CollapseLauncher/Classes/ShortcutCreator/SteamShortcut.cs index d9aa12450..4e84b022c 100644 --- a/CollapseLauncher/Classes/ShortcutCreator/SteamShortcut.cs +++ b/CollapseLauncher/Classes/ShortcutCreator/SteamShortcut.cs @@ -190,8 +190,7 @@ private static async ValueTask DownloadImage(FileInfo fileInfo, string url, Canc { Access = FileAccess.Write, Mode = FileMode.Create, - Share = FileShare.ReadWrite, - Options = FileOptions.Asynchronous + Share = FileShare.ReadWrite }); // Get the file length diff --git a/Hi3Helper.CommunityToolkit/ImageCropper/packages.lock.json b/Hi3Helper.CommunityToolkit/ImageCropper/packages.lock.json index 1f0f373d5..4fd919ca2 100644 --- a/Hi3Helper.CommunityToolkit/ImageCropper/packages.lock.json +++ b/Hi3Helper.CommunityToolkit/ImageCropper/packages.lock.json @@ -26,12 +26,6 @@ "Microsoft.WindowsAppSDK": "1.5.240311000" } }, - "Microsoft.DotNet.ILCompiler": { - "type": "Direct", - "requested": "[9.0.0-rc.2.24473.5, )", - "resolved": "9.0.0-rc.2.24473.5", - "contentHash": "+4KH+fbuWXX+I1nM+iP84N0nnorwxY3N8SrNLDNdWdblCPcWXSZnnst/IS+NEHTavnoTErwFNwk7IP8rPrNAQA==" - }, "Microsoft.Graphics.Win2D": { "type": "Direct", "requested": "[1.3.0, )", @@ -92,15 +86,6 @@ } }, "net9.0-windows10.0.22621/win-x64": { - "Microsoft.DotNet.ILCompiler": { - "type": "Direct", - "requested": "[9.0.0-rc.2.24473.5, )", - "resolved": "9.0.0-rc.2.24473.5", - "contentHash": "+4KH+fbuWXX+I1nM+iP84N0nnorwxY3N8SrNLDNdWdblCPcWXSZnnst/IS+NEHTavnoTErwFNwk7IP8rPrNAQA==", - "dependencies": { - "runtime.win-x64.Microsoft.DotNet.ILCompiler": "9.0.0-rc.2.24473.5" - } - }, "Microsoft.Graphics.Win2D": { "type": "Direct", "requested": "[1.3.0, )", @@ -125,11 +110,6 @@ "Microsoft.Web.WebView2": "1.0.2651.64", "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" } - }, - "runtime.win-x64.Microsoft.DotNet.ILCompiler": { - "type": "Transitive", - "resolved": "9.0.0-rc.2.24473.5", - "contentHash": "gtZORh0O2hlNn8D+ezseJs1SEAI83Ca+LC8vmAIqaYUbiAn5+6iqD+ytuztGo4Thjr/2qWXKn3l7GGQEQiCJMg==" } } } diff --git a/Hi3Helper.CommunityToolkit/SettingsControls/packages.lock.json b/Hi3Helper.CommunityToolkit/SettingsControls/packages.lock.json index 582f6a323..c404efbf0 100644 --- a/Hi3Helper.CommunityToolkit/SettingsControls/packages.lock.json +++ b/Hi3Helper.CommunityToolkit/SettingsControls/packages.lock.json @@ -13,12 +13,6 @@ "Microsoft.WindowsAppSDK": "1.5.240311000" } }, - "Microsoft.DotNet.ILCompiler": { - "type": "Direct", - "requested": "[9.0.0-rc.2.24473.5, )", - "resolved": "9.0.0-rc.2.24473.5", - "contentHash": "+4KH+fbuWXX+I1nM+iP84N0nnorwxY3N8SrNLDNdWdblCPcWXSZnnst/IS+NEHTavnoTErwFNwk7IP8rPrNAQA==" - }, "Microsoft.NET.ILLink.Tasks": { "type": "Direct", "requested": "[9.0.0-rc.2.24473.5, )", @@ -80,15 +74,6 @@ } }, "net9.0-windows10.0.22621/win-x64": { - "Microsoft.DotNet.ILCompiler": { - "type": "Direct", - "requested": "[9.0.0-rc.2.24473.5, )", - "resolved": "9.0.0-rc.2.24473.5", - "contentHash": "+4KH+fbuWXX+I1nM+iP84N0nnorwxY3N8SrNLDNdWdblCPcWXSZnnst/IS+NEHTavnoTErwFNwk7IP8rPrNAQA==", - "dependencies": { - "runtime.win-x64.Microsoft.DotNet.ILCompiler": "9.0.0-rc.2.24473.5" - } - }, "Microsoft.Web.WebView2": { "type": "Direct", "requested": "[1.0.2895-prerelease, )", @@ -104,11 +89,6 @@ "Microsoft.Web.WebView2": "1.0.2651.64", "Microsoft.Windows.SDK.BuildTools": "10.0.22621.756" } - }, - "runtime.win-x64.Microsoft.DotNet.ILCompiler": { - "type": "Transitive", - "resolved": "9.0.0-rc.2.24473.5", - "contentHash": "gtZORh0O2hlNn8D+ezseJs1SEAI83Ca+LC8vmAIqaYUbiAn5+6iqD+ytuztGo4Thjr/2qWXKn3l7GGQEQiCJMg==" } } } diff --git a/Hi3Helper.Core/packages.lock.json b/Hi3Helper.Core/packages.lock.json index cacd64101..4167108f2 100644 --- a/Hi3Helper.Core/packages.lock.json +++ b/Hi3Helper.Core/packages.lock.json @@ -2,12 +2,6 @@ "version": 1, "dependencies": { "net9.0-windows10.0.22621": { - "Microsoft.DotNet.ILCompiler": { - "type": "Direct", - "requested": "[9.0.0-rc.2.24473.5, )", - "resolved": "9.0.0-rc.2.24473.5", - "contentHash": "+4KH+fbuWXX+I1nM+iP84N0nnorwxY3N8SrNLDNdWdblCPcWXSZnnst/IS+NEHTavnoTErwFNwk7IP8rPrNAQA==" - }, "Microsoft.NET.ILLink.Tasks": { "type": "Direct", "requested": "[9.0.0-rc.2.24473.5, )", diff --git a/InnoSetupHelper/packages.lock.json b/InnoSetupHelper/packages.lock.json index f106f17f0..3a864d87f 100644 --- a/InnoSetupHelper/packages.lock.json +++ b/InnoSetupHelper/packages.lock.json @@ -2,12 +2,6 @@ "version": 1, "dependencies": { "net9.0": { - "Microsoft.DotNet.ILCompiler": { - "type": "Direct", - "requested": "[9.0.0-rc.2.24473.5, )", - "resolved": "9.0.0-rc.2.24473.5", - "contentHash": "+4KH+fbuWXX+I1nM+iP84N0nnorwxY3N8SrNLDNdWdblCPcWXSZnnst/IS+NEHTavnoTErwFNwk7IP8rPrNAQA==" - }, "Microsoft.NET.ILLink.Tasks": { "type": "Direct", "requested": "[9.0.0-rc.2.24473.5, )",