Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 5c98207

Browse files
author
wanderer
committed
下载失败的时候就停止下载,并返回错误
1 parent 2963ab6 commit 5c98207

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

GameFramework/Runtime/Resource/ResourceVersion.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,14 @@ private void DownloadFiles(List<AssetHashInfo> needDownloadFiles,Action<float, d
358358
else
359359
{
360360
File.Delete(localPath);
361+
_webRequest.FileDownloader.StopDownload();
361362
//throw new GameException($"File integrity verification failed. {localPath}");
362363
errorCallback?.Invoke(localPath, "File integrity verification failed.");
364+
363365
}
364366
}, (localPath, error) =>
365367
{
368+
_webRequest.FileDownloader.StopDownload();
366369
errorCallback?.Invoke(localPath, error);
367370
});
368371
}

GameFramework/Runtime/WebRequest/FileDownloader.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ public void OnUpdate()
7979
{
8080
if (_downloadingFiles.Count == 0)
8181
{
82-
Downloading = false;
83-
//下载回调
84-
_downloadCallback = null;
85-
_downloadCompleteCallback = null;
86-
_downloadErrorCallback = null;
82+
StopDownload();
8783
}
8884
}
8985
}
@@ -123,6 +119,24 @@ public bool StartDownload(Action<string, double, float, double> downloadCallback
123119
return true;
124120
}
125121

122+
123+
/// <summary>
124+
/// 停止下载
125+
/// </summary>
126+
public void StopDownload()
127+
{
128+
if (Downloading)
129+
{
130+
//下载回调
131+
_downloadCallback = null;
132+
_downloadCompleteCallback = null;
133+
_downloadErrorCallback = null;
134+
_downloadingFiles.Clear();
135+
_remainingFiles.Clear();
136+
Downloading = false;
137+
}
138+
}
139+
126140
#endregion
127141

128142
#region 事件回调

0 commit comments

Comments
 (0)