From 8725821a2705e3985e75085b1fdef3bd2e44c864 Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 25 Aug 2023 20:15:58 +0800 Subject: [PATCH] update download system --- .../Downloader/FileGeneralDownloader.cs | 10 +++++++--- .../Downloader/FileResumeDownloader.cs | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileGeneralDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileGeneralDownloader.cs index c9fca2b..5d737bf 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileGeneralDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileGeneralDownloader.cs @@ -51,6 +51,9 @@ namespace YooAsset // 准备下载 if (_steps == ESteps.PrepareDownload) { + // 获取请求地址 + _requestURL = GetRequestURL(); + // 重置变量 _downloadProgress = 0f; _downloadedBytes = 0; @@ -59,14 +62,16 @@ namespace YooAsset _isAbort = false; _latestDownloadBytes = 0; _latestDownloadRealtime = Time.realtimeSinceStartup; + + // 重置计时器 + if(_tryAgainTimer > 0f) + YooLogger.Warning($"Try again download : {_requestURL}"); _tryAgainTimer = 0f; // 删除临时文件 if (File.Exists(_tempFilePath)) File.Delete(_tempFilePath); - // 获取请求地址 - _requestURL = GetRequestURL(); _steps = ESteps.CreateDownloader; } @@ -197,7 +202,6 @@ namespace YooAsset _failedTryAgain--; _steps = ESteps.PrepareDownload; ReportWarning(); - YooLogger.Warning($"Try again download : {_requestURL}"); } } } diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileResumeDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileResumeDownloader.cs index 070f7c4..f117d14 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileResumeDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileResumeDownloader.cs @@ -91,6 +91,9 @@ namespace YooAsset // 创建下载器 if (_steps == ESteps.PrepareDownload) { + // 获取请求地址 + _requestURL = GetRequestURL(); + // 重置变量 _downloadProgress = 0f; _downloadedBytes = 0; @@ -99,11 +102,13 @@ namespace YooAsset _isAbort = false; _latestDownloadBytes = 0; _latestDownloadRealtime = Time.realtimeSinceStartup; - _tryAgainTimer = 0f; _fileOriginLength = 0; - // 获取请求地址 - _requestURL = GetRequestURL(); + // 重置计时器 + if (_tryAgainTimer > 0f) + YooLogger.Warning($"Try again download : {_requestURL}"); + _tryAgainTimer = 0f; + _steps = ESteps.CreateDownloader; } @@ -257,7 +262,6 @@ namespace YooAsset _failedTryAgain--; _steps = ESteps.PrepareDownload; ReportWarning(); - YooLogger.Warning($"Try again download : {_requestURL}"); } } }