Skip to content

Commit 78cb7fb

Browse files
committed
✨ 修复下载进度超过100的情况
1 parent 67d4974 commit 78cb7fb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Extensions/YooAsset.CLI/Runtime/1.5.7/Downloader/YAssetProxy.Downloader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ private void CollectNeedBegin()
326326

327327
private Dictionary<string, long> CurrentValueDict = new Dictionary<string, long>();
328328
private Dictionary<string, long> TotalValueDict = new Dictionary<string, long>();
329-
private Dictionary<string, long> DownloadedFiles = new Dictionary<string, long>();
330329

331330
private long FirstValue = -1;
332331

@@ -335,8 +334,6 @@ private bool OnWaitBegin()
335334
CurrentValueDict.Clear();
336335
TotalValueDict.Clear();
337336

338-
CurrentValueDict[nameof(DownloadedFiles)] = DownloadedFiles.Sum(pair => pair.Value);
339-
340337
foreach (var pair in ResourceDownloaderOperations)
341338
{
342339
TotalValueDict[pair.Key] = pair.Value.TotalDownloadBytes;
@@ -346,6 +343,11 @@ private bool OnWaitBegin()
346343
if (FirstValue < 0)
347344
{
348345
FirstValue = TotalValue = TotalValueDict.Sum(pair => pair.Value);
346+
CurrentValue = CurrentValueDict.Sum(pair => pair.Value);
347+
}
348+
else
349+
{
350+
CurrentValueDict[nameof(FirstValue)] = FirstValue - TotalValueDict.Sum(pair => pair.Value);
349351
}
350352

351353
CurrentValue = CurrentValueDict.Sum(pair => pair.Value);
@@ -505,14 +507,12 @@ protected override IEnumerator OnWaitCo()
505507

506508
private void OnStartDownloadFileCallback(string filename, long sizeBytes)
507509
{
508-
DownloadedFiles[filename] = sizeBytes;
509510
CurrentInfo = $"Resource download : [{filename}:{sizeBytes}]";
510511
AssetSystem.Log($"Resource download : [{filename}:{sizeBytes}]");
511512
}
512513

513514
private void OnDownloadError(string filename, string error)
514515
{
515-
DownloadedFiles.Remove(filename);
516516
var ex = new SystemException($"{filename} : {error}");
517517
if (Event.OnError is null) throw ex;
518518
Event.OnError.Invoke(ex);

0 commit comments

Comments
 (0)