From 8c5875afbe96f16e4324d3d5c56b582bb49710c1 Mon Sep 17 00:00:00 2001 From: Kemal Setya Adhi Date: Sun, 19 Nov 2023 22:51:43 +0700 Subject: [PATCH] Fix HSR Delta-patching not working on moving files --- .../Classes/RepairManagement/StarRail/Fetch.cs | 17 +++++++++++------ CollapseLauncher/packages.lock.json | 6 ------ .../ClassStruct/Class/GameDataStructure.cs | 13 +++++++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CollapseLauncher/Classes/RepairManagement/StarRail/Fetch.cs b/CollapseLauncher/Classes/RepairManagement/StarRail/Fetch.cs index fdbd65411..e4b1a8607 100644 --- a/CollapseLauncher/Classes/RepairManagement/StarRail/Fetch.cs +++ b/CollapseLauncher/Classes/RepairManagement/StarRail/Fetch.cs @@ -36,9 +36,15 @@ private async Task Fetch(List assetIndex, CancellationToke Dictionary hashtable = new Dictionary(); await GetPrimaryManifest(httpClient, token, assetIndex, hashtable); - // If the this._isOnlyRecoverMain && base._isVersionOverride is true, store the _originAssetIndex from assetIndex + // If the this._isOnlyRecoverMain && base._isVersionOverride is true, copy the asset index into the _originAssetIndex if (this._isOnlyRecoverMain && base._isVersionOverride) - _originAssetIndex = new List(assetIndex); + { + _originAssetIndex = new List(); + foreach (FilePropertiesRemote asset in assetIndex) + { + _originAssetIndex.Add(asset.Copy()); + } + } // Subscribe the fetching progress and subscribe StarRailMetadataTool progress to adapter _innerGameVersionManager.StarRailMetadataTool.HttpEvent += _httpClient_FetchAssetProgress; @@ -82,7 +88,7 @@ private async Task GetPrimaryManifest(Http client, CancellationToken token, List List pkgVersion = new List(); // Initialize repo metadata - bool isSuccess = true; + bool isSuccess = false; try { // Get the metadata @@ -100,9 +106,8 @@ private async Task GetPrimaryManifest(Http client, CancellationToken token, List // If the base._isVersionOverride is true, then throw. This sanity check is required if the delta patch is being performed. catch when (base._isVersionOverride) { throw; } - // If the base._isVersionOverride is false and the repo metadata is null, - // then fetch the asset index from CDN (also check if the status is success) - if (!base._isVersionOverride && isSuccess) + // Fetch the asset index from CDN (also check if the status is success) + if (isSuccess) { // Set asset index URL string urlIndex = string.Format(LauncherConfig.AppGameRepairIndexURLPrefix, _gameVersionManager.GamePreset.ProfileName, _gameVersion.VersionString) + ".bin"; diff --git a/CollapseLauncher/packages.lock.json b/CollapseLauncher/packages.lock.json index 2cf4bf87b..1cc24753d 100644 --- a/CollapseLauncher/packages.lock.json +++ b/CollapseLauncher/packages.lock.json @@ -96,12 +96,6 @@ "Microsoft.WindowsAppSDK": "1.4.230913002" } }, - "Microsoft.NET.ILLink.Tasks": { - "type": "Direct", - "requested": "[8.0.0, )", - "resolved": "8.0.0", - "contentHash": "B3etT5XQ2nlWkZGO2m/ytDYrOmSsQG1XNBaM6ZYlX5Ch/tDrMFadr0/mK6gjZwaQc55g+5+WZMw4Cz3m8VEF7g==" - }, "Microsoft.Windows.CsWin32": { "type": "Direct", "requested": "[0.3.49-beta, )", diff --git a/Hi3Helper.Core/Classes/Shared/ClassStruct/Class/GameDataStructure.cs b/Hi3Helper.Core/Classes/Shared/ClassStruct/Class/GameDataStructure.cs index 547596d80..25936e8a5 100644 --- a/Hi3Helper.Core/Classes/Shared/ClassStruct/Class/GameDataStructure.cs +++ b/Hi3Helper.Core/Classes/Shared/ClassStruct/Class/GameDataStructure.cs @@ -26,6 +26,19 @@ public class FilePropertiesRemote : IAssetIndexSummary public bool IsBlockNeedRepair { get; set; } public bool IsHasHashMark { get; set; } + public FilePropertiesRemote Copy() => new FilePropertiesRemote + { + N = N, + RN = RN, + CRC = CRC, + M = M, + FT = FT, + S = S, + IsPatchApplicable = IsPatchApplicable, + IsBlockNeedRepair = IsBlockNeedRepair, + IsHasHashMark = IsHasHashMark, + }; + public string PrintSummary() => $"File [T: {FT}]: {N}\t{SummarizeSizeSimple(S)} ({S} bytes)"; public long GetAssetSize() => FT == FileType.Unused ? 0 : S; public string GetRemoteURL() => RN;