Skip to content

Commit 1cea69a

Browse files
authored
[Hotfix] Preview 1.83.8 (#787)
# What's Changed? - **[Imp]** Update `System.Commandline` to `2.0.0beta6`, by @bagusnl, @shatyuka & @gablm - **[Imp]** Migrate `BridgedNetworkStream` & `CopyToStream` functions to `EncTool` submodule, by @neon-nyan - **[New]** Add caching for CDN responses, which will hopefully reduce the amount of network calls Collapse makes, by @neon-nyan - This is used as a cache utility for `HttpResponseMessage` saving responses locally based on the cache method used. Two cache methods are currently supported, including: - Time-based cache (based on Expire headers) - Hash-based cache (based on ETag or Content-MD5 headers) - **[Fix]** Restore deleted Sentry `csproj` entries for AOT builds, by @neon-nyan - **[Loc]** Add Thai localization to README (thanks!), by @armzyaec - **[Imp]** Improve Settings page based on changes made to CDN caching, by @neon-nyan: - Allow Cache Garbage Collection if the cache file age is more than allowed maximum time. - Allow time-based cache to be clamped if the CDN expire time is larger than allowed maximum time. - Adding Aggressive Caching mode. > This mode allow the response to be always cached based on how long the allowed maximum time. - Add new method: `SetCacheDirSkipGC` > This method is used to set the cache directory and skipping the garbage collection. - Ensure to always set `Length` as 0 if source stream's `.Length` isn't supported on `CopyToStream` - **[Imp]** Add new async methods for `DnsQuery` & fix marshalling issues in `Hi3Helper.Win32`, by @neon-nyan - **[Imp]** `HttpClientBuilder` improvements, by @neon-nyan: - Make DNS resolve from Client -> OS fully asynchronous - Use shared DNS Nameservers instead of per-`HttpClient` > This way, the users can change the DNS settings without restarting the app. - Remove `HttpClientBuilder<THandler>` and instead explicitly use `SocketsHttpHandler` via `HttpClientBuilder` - **[Fix]** Fix incorrect i18n string used for Anisotropic Filtering in ZZZ, by @shatyuka - **[Imp]** Update `SRAM` version & parsing to account for new HSR asset type in version 3.5.0. - **[Imp]** Update .NET components NuGet to 9.0.7, by @bagusnl - **[Loc]** Update localizations, by our Localizers. Thanks for all your hard work ❤️
2 parents cedf291 + 1ce3064 commit 1cea69a

File tree

85 files changed

+2180
-1149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2180
-1149
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## Localization Contribution(s)
1313
You can help us add or proofread localization changes for [Collapse on Transifex!](https://explore.transifex.com/collapse-launcher/collapse-mainapp/)
14-
If you wish to add new language that isn't yet listed in the Crowdin project, please create an issue either in GitHub or create a discussion through Crowdin itself. We'll do our best to get back to you in a timely manner.
14+
If you wish to add new language that isn't yet listed in the Transifex project, please create an issue either in GitHub or create a discussion through Transifex itself. We'll do our best to get back to you in a timely manner.
1515

1616
## Tools Needed
1717
Below is a list of tools needed to contribute to this project:

CollapseLauncher/Classes/CachesManagement/Honkai/Fetch.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,8 @@ private async Task<List<CacheAsset>> Fetch(CancellationToken token)
3838
.SetAllowedDecompression(DecompressionMethods.None)
3939
.Create();
4040

41-
// Use a new DownloadClient for fetching
42-
DownloadClient downloadClient = DownloadClient.CreateInstance(httpClientNew);
43-
4441
// Build _gameRepoURL from loading Dispatcher and Gateway
45-
await BuildGameRepoURL(downloadClient, token);
42+
await BuildGameRepoURL(httpClientNew, token);
4643

4744
// Iterate type and do fetch
4845
await Parallel.ForEachAsync(
@@ -62,7 +59,7 @@ await Parallel.ForEachAsync(
6259
{
6360
// uint = Count of the assets available
6461
// long = Total size of the assets available
65-
(int, long) count = await FetchByType(type, downloadClient, returnAsset, ctx);
62+
(int, long) count = await FetchByType(type, httpClientNew, returnAsset, ctx);
6663

6764
// Write a log about the metadata
6865
LogWriteLine($"Cache Metadata [T: {type}]:", LogType.Default, true);
@@ -83,7 +80,7 @@ await Parallel.ForEachAsync(
8380
return returnAsset;
8481
}
8582

86-
private async Task BuildGameRepoURL(DownloadClient downloadClient, CancellationToken token)
83+
private async Task BuildGameRepoURL(HttpClient client, CancellationToken token)
8784
{
8885
KianaDispatch dispatch = null;
8986
Exception lastException = null;
@@ -101,10 +98,13 @@ private async Task BuildGameRepoURL(DownloadClient downloadClient, CancellationT
10198
string key = GameVersionManager.GamePreset.DispatcherKey;
10299

103100
// Try assign dispatcher
104-
dispatch = await KianaDispatch.GetDispatch(downloadClient, baseURL,
101+
dispatch = await KianaDispatch.GetDispatch(client,
102+
baseURL,
105103
GameVersionManager.GamePreset.GameDispatchURLTemplate,
106104
GameVersionManager.GamePreset.GameDispatchChannelName,
107-
key, GameVersion.VersionArray, token);
105+
key,
106+
GameVersion.VersionArray,
107+
token);
108108
lastException = null;
109109
break;
110110
}
@@ -119,13 +119,13 @@ private async Task BuildGameRepoURL(DownloadClient downloadClient, CancellationT
119119

120120
// Get gatewayURl and fetch the gateway
121121
GameGateway =
122-
await KianaDispatch.GetGameserver(downloadClient, dispatch!, GameVersionManager.GamePreset.GameGatewayDefault!, token);
122+
await KianaDispatch.GetGameserver(client, dispatch!, GameVersionManager.GamePreset.GameGatewayDefault!, token);
123123
GameRepoURL = BuildAssetBundleURL(GameGateway);
124124
}
125125

126126
private static string BuildAssetBundleURL(KianaDispatch gateway) => CombineURLFromString(gateway!.AssetBundleUrls![0], "/{0}/editor_compressed/");
127127

128-
private async Task<(int, long)> FetchByType(CacheAssetType type, DownloadClient downloadClient, List<CacheAsset> assetIndex, CancellationToken token)
128+
private async Task<(int, long)> FetchByType(CacheAssetType type, HttpClient client, List<CacheAsset> assetIndex, CancellationToken token)
129129
{
130130
// Set total activity string as "Fetching Caches Type: <type>"
131131
Status.ActivityStatus = string.Format(Lang!._CachesPage!.CachesStatusFetchingType!, type);
@@ -143,9 +143,7 @@ private async Task BuildGameRepoURL(DownloadClient downloadClient, CancellationT
143143
#endif
144144

145145
// Get a direct HTTP Stream
146-
await using HttpResponseInputStream remoteStream = await HttpResponseInputStream.CreateStreamAsync(
147-
downloadClient.GetHttpClient(), assetIndexURL, null, null, null, null, null, token);
148-
146+
await using Stream remoteStream = (await client.TryGetCachedStreamFrom(assetIndexURL, token: token)).Stream;
149147
await using XORStream stream = new XORStream(remoteStream);
150148

151149
// Build the asset index and return the count and size of each type
@@ -330,7 +328,7 @@ private byte[] GetAssetIndexSalt(string data)
330328
key = LauncherMetadataHelper.CurrentMasterKey?.Key;
331329
}
332330

333-
mhyEncTool saltTool = new mhyEncTool(data, key);
331+
MhyEncTool saltTool = new MhyEncTool(data, key);
334332
return saltTool.GetSalt();
335333
}
336334

@@ -347,17 +345,16 @@ private static bool IsValidRegionFile(string input, string lang)
347345

348346
public KianaDispatch GetCurrentGateway() => GameGateway;
349347

350-
public async Task<(List<CacheAsset>, string, string, int)> GetCacheAssetList(
351-
DownloadClient downloadClient, CacheAssetType type, CancellationToken token)
348+
public async Task<(List<CacheAsset>, string, string, int)> GetCacheAssetList(HttpClient client, CacheAssetType type, CancellationToken token)
352349
{
353350
// Initialize asset index for the return
354351
List<CacheAsset> returnAsset = [];
355352

356353
// Build _gameRepoURL from loading Dispatcher and Gateway
357-
await BuildGameRepoURL(downloadClient, token);
354+
await BuildGameRepoURL(client, token);
358355

359356
// Fetch the progress
360-
_ = await FetchByType(type, downloadClient, returnAsset, token);
357+
_ = await FetchByType(type, client, returnAsset, token);
361358

362359
// Return the list and base asset bundle repo URL
363360
return (returnAsset, GameGateway!.ExternalAssetUrls!.FirstOrDefault(), BuildAssetBundleURL(GameGateway),

CollapseLauncher/Classes/CachesManagement/Honkai/Update.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal partial class HonkaiCache
2424
private async Task<bool> Update(List<CacheAsset> updateAssetIndex, List<CacheAsset> assetIndex, CancellationToken token)
2525
{
2626
// Initialize new proxy-aware HttpClient
27-
using HttpClient client = new HttpClientBuilder<SocketsHttpHandler>()
27+
using HttpClient client = new HttpClientBuilder()
2828
.UseLauncherConfig(DownloadThreadWithReservedCount)
2929
.SetUserAgent(UserAgent)
3030
.SetAllowedDecompression(DecompressionMethods.None)

CollapseLauncher/Classes/CachesManagement/StarRail/Update.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal partial class StarRailCache
2626
private async Task<bool> Update(List<SRAsset> updateAssetIndex, List<SRAsset> assetIndex, CancellationToken token)
2727
{
2828
// Initialize new proxy-aware HttpClient
29-
using HttpClient client = new HttpClientBuilder<SocketsHttpHandler>()
29+
using HttpClient client = new HttpClientBuilder()
3030
.UseLauncherConfig(DownloadThreadWithReservedCount)
3131
.SetUserAgent(UserAgent)
3232
.SetAllowedDecompression(DecompressionMethods.None)

CollapseLauncher/Classes/Extension/VelopackLocatorExtension.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,23 @@ internal static void GenerateVelopackMetadata(string aumid)
274274
</metadata>
275275
</package>
276276
"""; // Adding shortcutAumid for future use, since they typo-ed the XML tag LMAO
277-
string currentVersion = LauncherUpdateHelper.LauncherCurrentVersionString;
278-
string xmlPath = Path.Combine(LauncherConfig.AppExecutableDir, "sq.version");
279-
string xmlContent = string.Format(xmlTemplate, currentVersion, LauncherConfig.IsPreview ? "preview" : "stable", aumid);
280-
File.WriteAllText(xmlPath, xmlContent.ReplaceLineEndings("\n"));
277+
var currentVersion = LauncherUpdateHelper.LauncherCurrentVersionString;
278+
var xmlPath = Path.Combine(LauncherConfig.AppExecutableDir, "sq.version");
279+
var xmlContent = string.Format(xmlTemplate, currentVersion, LauncherConfig.IsPreview ? "preview" : "stable",
280+
aumid).ReplaceLineEndings("\n");
281+
282+
// Check if file exist
283+
if (File.Exists(xmlPath))
284+
{
285+
// Check if the content is the same
286+
var existingContent = File.ReadAllText(xmlPath);
287+
if (existingContent.ReplaceLineEndings("\n").Equals(xmlContent, StringComparison.Ordinal))
288+
{
289+
Logger.LogWriteLine("Velopack metadata is already up-to-date, skipping write operation.", LogType.Default, true);
290+
return;
291+
}
292+
}
293+
File.WriteAllText(xmlPath, xmlContent);
281294
Logger.LogWriteLine($"Velopack metadata has been successfully written!\r\n{xmlContent}", LogType.Default, true);
282295
}
283296
}

CollapseLauncher/Classes/FileMigrationProcess/FileMigrationProcess.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Hi3Helper;
55
using Hi3Helper.Shared.Region;
66
using Hi3Helper.Win32.ManagedTools;
7-
using Hi3Helper.Win32.Native.ManagedTools;
87
using Microsoft.UI.Dispatching;
98
using System;
109
using System.Collections.Generic;

CollapseLauncher/Classes/FileMigrationProcess/Statics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace CollapseLauncher
1313
{
1414
internal partial class FileMigrationProcess
1515
{
16-
internal static async Task<FileMigrationProcess> CreateJob(string dialogTitle, string inputPath, string outputPath = null, CancellationTokenSource token = default, bool showWarningMessage = true)
16+
internal static async Task<FileMigrationProcess> CreateJob(string dialogTitle, string inputPath, string outputPath = null, CancellationTokenSource token = null, bool showWarningMessage = true)
1717
{
1818
// Normalize Path (also normalize path from '/' separator)
1919
inputPath = ConverterTool.NormalizePath(inputPath);

CollapseLauncher/Classes/GamePresetProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
using CollapseLauncher.Interfaces;
1313
using Hi3Helper;
1414
using Hi3Helper.SentryHelper;
15+
using Hi3Helper.Win32.ManagedTools;
1516
using Hi3Helper.Win32.Native.Enums;
16-
using Hi3Helper.Win32.Native.ManagedTools;
1717
using Microsoft.Extensions.Logging;
1818
using Microsoft.UI.Xaml;
1919
using System;

CollapseLauncher/Classes/Helper/Background/ColorPaletteUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private static async ValueTask<WColor[]> TryGenerateNewCachedPalette(BitmapInput
192192
Directory.CreateDirectory(cachedPaletteDirPath ?? "");
193193
}
194194

195-
if (!ConverterTool.TrySerializeStruct(colors, buffer, out int read))
195+
if (!ConverterTool.TrySerializeStruct(buffer, out int read, colors))
196196
{
197197
byte defVal = (byte)(isLight ? 80 : 255);
198198
WColor defColor =

0 commit comments

Comments
 (0)