Skip to content

Commit

Permalink
Fix double processing in Genshin Repair
Browse files Browse the repository at this point in the history
  • Loading branch information
bagusnl committed Nov 22, 2024
1 parent 978aa73 commit bdae71a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions CollapseLauncher/Classes/RepairManagement/Genshin/Repair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Hi3Helper.Data;
using Hi3Helper.EncTool.Parser.AssetIndex;
using Hi3Helper.Http;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
Expand Down Expand Up @@ -44,6 +45,7 @@ private async Task<bool> Repair(List<PkgVersionProperties> repairAssetIndex, Can
ObservableCollection<IAssetProperty> assetProperty = new ObservableCollection<IAssetProperty>(AssetEntry);
if (_isBurstDownloadEnabled)
{
var processingAsset = new ConcurrentDictionary<(PkgVersionProperties, IAssetProperty), byte>();
await Parallel.ForEachAsync(
PairEnumeratePropertyAndAssetIndexPackage(
#if ENABLEHTTPREPAIR
Expand All @@ -55,11 +57,19 @@ await Parallel.ForEachAsync(
new ParallelOptions { CancellationToken = token, MaxDegreeOfParallelism = _downloadThreadCount },
async (asset, innerToken) =>
{
if (!processingAsset.TryAdd(asset, 0))
{
LogWriteLine($"Asset {asset.AssetIndex.localName} is already being processed, skipping...",
LogType.Warning, true);
return;
}
await RepairAssetTypeGeneric(asset, downloadClient, _httpClient_RepairAssetProgress, innerToken);
processingAsset.TryRemove(asset, out _);
});
}
else
{
var processingAsset = new ConcurrentDictionary<(PkgVersionProperties, IAssetProperty), byte>();
foreach ((PkgVersionProperties AssetIndex, IAssetProperty AssetProperty) asset in
PairEnumeratePropertyAndAssetIndexPackage(
#if ENABLEHTTPREPAIR
Expand All @@ -69,7 +79,14 @@ await Parallel.ForEachAsync(
#endif
, assetProperty))
{
if (!processingAsset.TryAdd(asset, 0))
{
LogWriteLine($"Asset {asset.AssetIndex.localName} is already being processed, skipping...",
LogType.Warning, true);
continue;
}
await RepairAssetTypeGeneric(asset, downloadClient, _httpClient_RepairAssetProgress, token);
processingAsset.TryRemove(asset, out _);
}
}

Expand Down

0 comments on commit bdae71a

Please sign in to comment.