update download system

remove timeout
This commit is contained in:
何冠峰
2025-07-17 20:59:15 +08:00
parent dd6fab46f9
commit b3622167da
43 changed files with 321 additions and 210 deletions

View File

@@ -17,10 +17,18 @@ namespace YooAsset
private readonly string _fileSavePath;
private ESteps _steps = ESteps.None;
/// <summary>
/// 响应的超时时间单位在经过Timeout的秒数后尝试中止。
/// 注意当Timeout设置为0时不会应用超时。
/// 注意设置的超时值可能应用于Android上的每个URL重定向这可能会导致响应时间增加。
/// </summary>
private readonly int _timeout;
internal UnityWebFileRequestOperation(string url, string fileSavePath, int timeout = 60) : base(url, timeout)
internal UnityWebFileRequestOperation(string url, string fileSavePath, int timeout) : base(url)
{
_fileSavePath = fileSavePath;
_timeout = timeout;
}
internal override void InternalStart()
{
@@ -33,7 +41,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest)
{
ResetTimeout();
CreateWebRequest();
_steps = ESteps.Download;
}
@@ -44,10 +51,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress;
if (_requestOperation.isDone == false)
{
CheckRequestTimeout();
return;
}
if (CheckRequestResult())
{
@@ -67,9 +71,10 @@ namespace YooAsset
private void CreateWebRequest()
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerFile handler = new DownloadHandlerFile(_fileSavePath);
handler.removeFileOnAbort = true;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.timeout = _timeout;
_webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true;
_requestOperation = _webRequest.SendWebRequest();