Skip to content

Commit cedf291

Browse files
authored
[Hotfix] Preview 1.83.7 Release (#784)
# What's changed? - **[Fix]** [Sophon] Avoid Patch mode accidentally deleting files with no patch reference, by @neon-nyan - **[New]** [Sophon] Support / Adding compatibility to Read/Download Pre-loads From/To HoYoPlay's "Ldiff" folder, by @neon-nyan > Collapse will now automatically use "Ldiff" folder as its default destination for reading/downloading pre-load, making Collapse able to use patch that already been downloaded by HoYoPlay and use it for patch, or vice versa (Download the pre-load on Collapse, apply on HoYoPlay later) - **[Imp]** [Sophon] Reducing I/O overhead and improve read performances for Patch/Asset checking, by @neon-nyan - **[Imp]** Update NuGet, by @bagusnl - Microsoft.Web.WebView2: 1.0.3344-prerelease -> 1.0.3415-prerelease - Microsoft.WindowsAppSDK: 1.8.250515001-experimental2 -> 1.8.250702007-experimental4 ### Templates <details> <summary>Changelog Prefixes</summary> ``` **[New]** **[Imp]** **[Fix]** **[Loc]** **[Doc]** ``` </details>
2 parents acda66e + 872434e commit cedf291

24 files changed

+301
-224
lines changed

CollapseLauncher/Classes/InstallManagement/Base/InstallManagerBase.Sophon.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ await GameVersionManager.GamePreset
249249
Token.Token);
250250

251251
// Ensure that the manifest is ordered based on _gameVoiceLanguageLocaleIdOrdered
252-
RearrangeDataListLocaleOrder(sophonMainInfoPair.OtherSophonBuildData.ManifestIdentityList,
252+
RearrangeDataListLocaleOrder(sophonMainInfoPair.OtherSophonBuildData!.ManifestIdentityList,
253253
x => x.MatchingField);
254254

255255
// Add the manifest to the pair list
@@ -356,8 +356,8 @@ await SimpleDialogs.Dialog_ChooseAudioLanguageChoice(
356356
Token.Token);
357357

358358
// Get the remote total size and current total size
359-
ProgressAllCountTotal = sophonInfoPairList.Sum(x => x.ChunksInfo.FilesCount);
360-
ProgressAllSizeTotal = sophonInfoPairList.Sum(x => x.ChunksInfo.TotalSize);
359+
ProgressAllCountTotal = sophonInfoPairList.Sum(x => x.ChunksInfo!.FilesCount);
360+
ProgressAllSizeTotal = sophonInfoPairList.Sum(x => x.ChunksInfo!.TotalSize);
361361
ProgressAllSizeCurrent = 0;
362362

363363
// Check for the disk space requirement first and ensure that the space is sufficient
@@ -501,7 +501,7 @@ private async Task<List<SophonAsset>> GetSophonAssetListFromPair(
501501
foreach (SophonChunkManifestInfoPair sophonDownloadInfoPair in sophonInfoPairs)
502502
{
503503
// Try add and if the hashset already contains the same Manifest ID registered, then skip
504-
if (!currentlyProcessedPair.Add(sophonDownloadInfoPair.ManifestInfo.ManifestId))
504+
if (!currentlyProcessedPair.Add(sophonDownloadInfoPair.ManifestInfo!.ManifestId))
505505
{
506506
Logger.LogWriteLine($"Found duplicate operation for {sophonDownloadInfoPair.ManifestInfo.ManifestId}! Skipping...",
507507
LogType.Warning, true);
@@ -542,9 +542,9 @@ protected async Task ConfirmAdditionalInstallDataPackageFiles(
542542
return;
543543
}
544544

545-
List<string> matchingFieldsList = installManifest.Select(x => x.MatchingField).ToList();
545+
List<string> matchingFieldsList = installManifest.Select(x => x.MatchingField).ToList()!;
546546

547-
List<SophonManifestBuildIdentity> otherManifestIdentity = installManifestFirst.OtherSophonBuildData.ManifestIdentityList
547+
List<SophonManifestBuildIdentity> otherManifestIdentity = installManifestFirst.OtherSophonBuildData!.ManifestIdentityList
548548
.Where(x => !commonPackageMatchingFields.Contains(x.MatchingField, StringComparer.OrdinalIgnoreCase))
549549
.ToList();
550550

@@ -1027,7 +1027,7 @@ private async Task TryGetAdditionalPackageForSophonDiff(HttpClient
10271027
return;
10281028
}
10291029

1030-
List<string> additionalPackageMatchingFields = manifestPair.OtherSophonBuildData.ManifestIdentityList
1030+
List<string> additionalPackageMatchingFields = manifestPair.OtherSophonBuildData!.ManifestIdentityList
10311031
.Where(x => !CommonSophonPackageMatchingFields.Contains(x.MatchingField, StringComparer.OrdinalIgnoreCase))
10321032
.Select(x => x.MatchingField)
10331033
.ToList();
@@ -1081,13 +1081,13 @@ private async Task<bool> AddSophonDiffAssetsToList(HttpClient ht
10811081
return false;
10821082
}
10831083

1084-
RearrangeDataListLocaleOrder(requestPairTo.OtherSophonBuildData.ManifestIdentityList,
1084+
RearrangeDataListLocaleOrder(requestPairTo.OtherSophonBuildData!.ManifestIdentityList,
10851085
x => x.MatchingField);
10861086

10871087
if (requestPairFrom.IsFound)
10881088
{
10891089
// Ensure that the manifest is ordered based on _gameVoiceLanguageLocaleIdOrdered
1090-
RearrangeDataListLocaleOrder(requestPairFrom.OtherSophonBuildData.ManifestIdentityList,
1090+
RearrangeDataListLocaleOrder(requestPairFrom.OtherSophonBuildData!.ManifestIdentityList,
10911091
x => x.MatchingField);
10921092

10931093
// Add asset to the list

CollapseLauncher/Classes/InstallManagement/Base/InstallManagerBase.SophonPatch.cs

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ await SophonPatch.CreateSophonChunkManifestInfoPair(httpClient,
108108
SophonDownloadSpeedLimiter.CreateInstance(LauncherConfig.DownloadSpeedLimitCached);
109109

110110
// Get the patch assets to download
111-
(List<SophonPatchAsset>, List<SophonChunkManifestInfoPair>) patchAssets =
111+
(List<SophonPatchAsset> AssetList, List<SophonChunkManifestInfoPair> InfoPairs, bool IsAllowRemoveOldFile) patchAssets =
112112
await GetAlterSophonPatchAssets(httpClient,
113113
branchResources.PatchUrl,
114114
(isPreloadMode ? branchResources.PreloadUrl : branchResources.MainUrl) ?? "",
@@ -120,8 +120,9 @@ await GetAlterSophonPatchAssets(httpClient,
120120
// Start the patch pipeline
121121
await StartAlterSophonPatch(httpClient,
122122
isPreloadMode,
123-
patchAssets.Item1,
124-
patchAssets.Item2,
123+
patchAssets.AssetList,
124+
patchAssets.InfoPairs,
125+
patchAssets.IsAllowRemoveOldFile,
125126
downloadSpeedLimiter,
126127
maxThread,
127128
Token.Token);
@@ -135,7 +136,7 @@ protected virtual async Task ConfirmAdditionalPatchDataPackageFiles(SophonChunkM
135136
{
136137
string currentVersion = GameVersion.ToString();
137138

138-
List<SophonManifestPatchIdentity> otherManifestIdentity = patchManifest.OtherSophonPatchData.ManifestIdentityList
139+
List<SophonManifestPatchIdentity> otherManifestIdentity = patchManifest.OtherSophonPatchData!.ManifestIdentityList
139140
.Where(x => !CommonSophonPackageMatchingFields.Contains(x.MatchingField, StringComparer.OrdinalIgnoreCase))
140141
.ToList();
141142

@@ -303,7 +304,7 @@ protected async Task<bool> SpawnAdditionalPackageDownloadDialog(long baseDownloa
303304
return confirmAdditionalTag == ContentDialogResult.Primary;
304305
}
305306

306-
protected virtual async Task<(List<SophonPatchAsset>, List<SophonChunkManifestInfoPair>)>
307+
protected virtual async Task<(List<SophonPatchAsset> AssetList, List<SophonChunkManifestInfoPair> InfoPairs, bool IsAllowRemoveOldFile)>
307308
GetAlterSophonPatchAssets(HttpClient httpClient,
308309
string manifestUrl,
309310
string downloadOverUrl,
@@ -315,6 +316,7 @@ protected async Task<bool> SpawnAdditionalPackageDownloadDialog(long baseDownloa
315316
SophonChunkManifestInfoPair? rootPatchManifest = null;
316317
SophonChunkManifestInfoPair? rootMainManifest = null;
317318
List<(SophonChunkManifestInfoPair Patch, SophonChunkManifestInfoPair Main, bool IsCommon)> patchManifestList = [];
319+
bool isAlowRemoveOldFile = true;
318320

319321
// Iterate matching fields and get the patch metadata
320322
foreach (string matchingField in matchingFields)
@@ -338,8 +340,15 @@ protected async Task<bool> SpawnAdditionalPackageDownloadDialog(long baseDownloa
338340
Logger.LogWriteLine($"Getting diff for matching field: {matchingField}", LogType.Debug, true);
339341

340342
// Get the manifest pair based on the matching field
341-
SophonChunkManifestInfoPair patchManifest = rootPatchManifest
342-
.GetOtherPatchInfoPair(matchingField, updateVersionfrom);
343+
if (!rootPatchManifest
344+
.TryGetOtherPatchInfoPair(matchingField, updateVersionfrom, out var patchManifest))
345+
{
346+
Logger.LogWriteLine($"[InstallManagerBase::GetAlterSophonPatchAssets] Cannot find past-version patch manifest for matching field: {matchingField}, Skipping!",
347+
LogType.Warning,
348+
true);
349+
isAlowRemoveOldFile = false;
350+
continue;
351+
}
343352

344353
// Get the main manifest pair based on the matching field
345354
SophonChunkManifestInfoPair mainManifest = rootMainManifest
@@ -364,18 +373,38 @@ protected async Task<bool> SpawnAdditionalPackageDownloadDialog(long baseDownloa
364373
{
365374
// Get the asset and add it to the list
366375
await foreach (SophonPatchAsset patchAsset in SophonPatch
367-
.EnumerateUpdateAsync(httpClient,
368-
manifestPair.Patch,
369-
manifestPair.Main,
370-
updateVersionfrom,
371-
downloadLimiter,
372-
token))
376+
.EnumerateUpdateAsync(httpClient,
377+
manifestPair.Patch,
378+
manifestPair.Main,
379+
updateVersionfrom,
380+
downloadLimiter,
381+
token))
373382
{
374383
patchAssets.Add(patchAsset);
375384
}
376385
}
377386

378-
return (patchAssets, patchManifestList.Select(x => x.Patch).ToList());
387+
// Find the removable assets and compare with the added list.
388+
List<SophonPatchAsset> removableAssets = [];
389+
foreach (var manifestPair in patchManifestList)
390+
{
391+
// Get the asset and add it to the list
392+
await foreach (SophonPatchAsset patchAsset in SophonPatch
393+
.EnumerateRemovableAsync(httpClient,
394+
manifestPair.Patch,
395+
manifestPair.Main,
396+
updateVersionfrom,
397+
patchAssets,
398+
token))
399+
{
400+
removableAssets.Add(patchAsset);
401+
}
402+
}
403+
404+
// Add the removable list to patch assets.
405+
patchAssets.AddRange(removableAssets);
406+
407+
return (patchAssets, patchManifestList.Select(x => x.Patch).ToList(), isAlowRemoveOldFile);
379408
}
380409

381410
protected virtual async Task<List<string>> GetAlterSophonPatchVOMatchingFields(CancellationToken token)
@@ -403,13 +432,14 @@ protected virtual async Task<List<string>> GetAlterSophonPatchVOMatchingFields(C
403432
return voAudioMatchingFields;
404433
}
405434

406-
protected virtual async Task StartAlterSophonPatch(HttpClient httpClient,
407-
bool isPreloadMode,
408-
List<SophonPatchAsset> patchAssets,
435+
protected virtual async Task StartAlterSophonPatch(HttpClient httpClient,
436+
bool isPreloadMode,
437+
List<SophonPatchAsset> patchAssets,
409438
List<SophonChunkManifestInfoPair> patchManifestInfoPairs,
410-
SophonDownloadSpeedLimiter downloadLimiter,
411-
int threadNum,
412-
CancellationToken token)
439+
bool isAllowRemoveOldFile,
440+
SophonDownloadSpeedLimiter downloadLimiter,
441+
int threadNum,
442+
CancellationToken token)
413443
{
414444
Dictionary<string, int> downloadedPatchHashSet = new();
415445
Lock dictionaryLock = new();
@@ -435,7 +465,7 @@ protected virtual async Task StartAlterSophonPatch(HttpClient httpClient,
435465
parallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount;
436466
}
437467

438-
string patchOutputDir = _gameSophonChunkDir;
468+
string patchOutputDir = Path.Combine(GamePath, "ldiff");
439469

440470
// Get download sizes
441471
long downloadSizeTotalAssetRemote = patchAssets.Where(x => x.PatchMethod != SophonPatchMethod.Remove).Sum(x => x.TargetFileSize);
@@ -555,7 +585,7 @@ async ValueTask ImplPatchUpdate(Tuple<SophonPatchAsset, Dictionary<string, int>>
555585
await patchAsset.ApplyPatchUpdateAsync(httpClient,
556586
GamePath,
557587
patchOutputDir,
558-
true,
588+
isAllowRemoveOldFile,
559589
read =>
560590
{
561591
UpdateSophonFileDownloadProgress(0, read);

CollapseLauncher/CollapseLauncher.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<Authors>$(Company). neon-nyan, Cry0, bagusnl, shatyuka, gablm.</Authors>
1717
<Copyright>Copyright 2022-2025 $(Company)</Copyright>
1818
<!-- Versioning -->
19-
<Version>1.83.6</Version>
19+
<Version>1.83.7</Version>
2020
<LangVersion>preview</LangVersion>
2121
<!-- Target Settings -->
2222
<Platforms>x64</Platforms>
@@ -197,10 +197,10 @@
197197
<PackageReference Include="Markdig.Signed" Version="0.41.3" />
198198
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.3.2" />
199199
<PackageReference Include="Microsoft.NETCore.Targets" Version="6.0.0-preview.4.21253.7" />
200-
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3344-prerelease" />
200+
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3415-prerelease" />
201201
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.2.0" />
202202
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4188" />
203-
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.250515001-experimental2" />
203+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.250702007-experimental4" />
204204
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="3.0.0" />
205205
<PackageReference Include="PhotoSauce.MagicScaler" Version="0.15.0" />
206206
<PackageReference Include="PhotoSauce.NativeCodecs.Libwebp" Version="*-*" />

0 commit comments

Comments
 (0)