Skip to content

Commit f87ef76

Browse files
committed
Fix deleted files re-downloaded on ZZZ and HSR update
Just realized that the filtering of the asset is still being redirected to FilterSophonPatchAssetList, which is unused rather than to FilterAssetList. This causes the supposedly deleted assets to get included, causing files to be redownloaded if not exist
1 parent 55f4403 commit f87ef76

File tree

3 files changed

+13
-25
lines changed

3 files changed

+13
-25
lines changed

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ await TryGetAdditionalPackageForSophonDiff(httpClient,
796796
}
797797

798798
// Filter asset list
799-
await FilterSophonPatchAssetList(sophonUpdateAssetList, Token!.Token);
799+
await FilterAssetList(sophonUpdateAssetList, x => x.AssetName, Token!.Token);
800800

801801
// Get the remote chunk size
802802
ProgressPerFileSizeTotal = sophonUpdateAssetList.GetCalculatedDiffSize(!isPreloadMode);
@@ -925,12 +925,6 @@ await Parallel.ForEachAsync(sophonUpdateAssetList
925925
}
926926
}
927927

928-
protected virtual Task FilterSophonPatchAssetList(List<SophonAsset> itemList, CancellationToken token)
929-
{
930-
// NOP
931-
return Task.CompletedTask;
932-
}
933-
934928
private ValueTask RunSophonAssetDownloadThread(HttpClient client,
935929
SophonAsset asset,
936930
ParallelOptions parallelOptions)

CollapseLauncher/Classes/InstallManagement/StarRail/StarRailInstall.SophonPatch.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Hi3Helper.Data;
1+
using Hi3Helper;
2+
using Hi3Helper.Data;
23
using System;
34
using System.Buffers;
45
using System.Collections.Generic;
@@ -62,9 +63,13 @@ public override async Task FilterAssetList<T>(
6263
continue;
6364
}
6465

66+
ConverterTool.NormalizePathInplaceNoTrim(filePath);
67+
6568
int indexOfAny = filePath.IndexOfAny(searchValues);
6669
if (indexOfAny >= 0)
6770
{
71+
Logger.LogWriteLine($"[StarRailInstall::FilterAssetList] Asset: {patchAsset} is ignored due to marked as deleted asset.",
72+
writeToLog: true);
6873
continue;
6974
}
7075

@@ -90,12 +95,9 @@ static ReadOnlySpan<char> GetFilePathFromJson(ReadOnlySpan<char> line)
9095
line = line[(firstIndexOf + first.Length)..];
9196
int endIndexOf = line.IndexOf(end);
9297

93-
if (endIndexOf <= 0)
94-
{
95-
return ReadOnlySpan<char>.Empty;
96-
}
97-
98-
return line[..endIndexOf];
98+
return endIndexOf <= 0
99+
? ReadOnlySpan<char>.Empty
100+
: line[..endIndexOf];
99101
}
100102
}
101103

CollapseLauncher/Classes/InstallManagement/Zenless/ZenlessInstall.SophonPatch.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
using Hi3Helper.Sophon;
2-
using Hi3Helper.Sophon.Infos;
1+
using Hi3Helper;
32
using Hi3Helper.Sophon.Structs;
43
using System;
54
using System.Buffers;
65
using System.Collections.Generic;
76
using System.IO;
8-
using System.Runtime.CompilerServices;
97
using System.Threading;
108
using System.Threading.Tasks;
119
// ReSharper disable CheckNamespace
@@ -17,14 +15,6 @@ internal partial class ZenlessInstall
1715
{
1816
private const StringSplitOptions SplitOptions = StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries;
1917

20-
// ReSharper disable once StringLiteralTypo
21-
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<SophonChunksInfo>k__BackingField")]
22-
private static extern ref SophonChunksInfo GetChunkAssetChunksInfo(SophonAsset element);
23-
24-
// ReSharper disable once StringLiteralTypo
25-
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<SophonChunksInfoAlt>k__BackingField")]
26-
private static extern ref SophonChunksInfo GetChunkAssetChunksInfoAlt(SophonAsset element);
27-
2818
public override async Task FilterAssetList<T>(
2919
List<T> itemList,
3020
Func<T, string?> itemPathSelector,
@@ -67,6 +57,8 @@ private static void FilterSophonAsset<T>(List<T> itemList, HashSet<string> excep
6757
if (asset is SophonIdentifiableProperty { MatchingField: { } assetMatchingField } &&
6858
exceptMatchFieldHashSet.Contains(assetMatchingField))
6959
{
60+
Logger.LogWriteLine($"[ZenlessInstall::FilterSophonAsset] Asset: {asset} is ignored due to marked as deleted asset.",
61+
writeToLog: true);
7062
continue;
7163
}
7264

0 commit comments

Comments
 (0)