Skip to content

Commit

Permalink
Fix HSR Delta-patching not working on moving files
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Nov 19, 2023
1 parent 57cd2e3 commit 8c5875a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
17 changes: 11 additions & 6 deletions CollapseLauncher/Classes/RepairManagement/StarRail/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ private async Task Fetch(List<FilePropertiesRemote> assetIndex, CancellationToke
Dictionary<string, int> hashtable = new Dictionary<string, int>();
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<FilePropertiesRemote>(assetIndex);
{
_originAssetIndex = new List<FilePropertiesRemote>();
foreach (FilePropertiesRemote asset in assetIndex)
{
_originAssetIndex.Add(asset.Copy());
}
}

// Subscribe the fetching progress and subscribe StarRailMetadataTool progress to adapter
_innerGameVersionManager.StarRailMetadataTool.HttpEvent += _httpClient_FetchAssetProgress;
Expand Down Expand Up @@ -82,7 +88,7 @@ private async Task GetPrimaryManifest(Http client, CancellationToken token, List
List<PkgVersionProperties> pkgVersion = new List<PkgVersionProperties>();

// Initialize repo metadata
bool isSuccess = true;
bool isSuccess = false;
try
{
// Get the metadata
Expand All @@ -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";
Expand Down
6 changes: 0 additions & 6 deletions CollapseLauncher/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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, )",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8c5875a

Please sign in to comment.