修复解压行为在包体内文件被篡改后,会无限尝试的问题。
This commit is contained in:
何冠峰
2026-06-02 14:37:11 +08:00
parent a5f4b555e7
commit 54d1593dd2
3 changed files with 10 additions and 1 deletions

View File

@@ -95,7 +95,8 @@ namespace YooAsset
} }
else else
{ {
if (IsWaitForAsyncComplete == false && _failedTryAgain > 0) // 注意:本地文件(解压/导入)校验失败属于确定性失败,重试只会重复读取同一文件,直接判定失败防止无限重试。
if (IsWaitForAsyncComplete == false && _failedTryAgain > 0 && _unityDownloadFileOp.VerifyFailed == false)
{ {
_steps = ESteps.TryAgain; _steps = ESteps.TryAgain;
YooLogger.Warning($"Failed download : {_unityDownloadFileOp.URL} Try again !"); YooLogger.Warning($"Failed download : {_unityDownloadFileOp.URL} Try again !");

View File

@@ -27,6 +27,12 @@ namespace YooAsset
/// </summary> /// </summary>
public int RefCount { private set; get; } public int RefCount { private set; get; }
/// <summary>
/// 文件校验是否失败
/// 注意:本地文件(解压/导入)校验失败属于确定性失败,重试无意义,上层不应重试。
/// </summary>
public bool VerifyFailed { protected set; get; } = false;
internal UnityDownloadFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url) : base(url) internal UnityDownloadFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url) : base(url)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;

View File

@@ -133,6 +133,8 @@ namespace YooAsset
} }
else else
{ {
// 注意:本地内置文件被篡改或损坏时校验会失败,重试只会重复读取同一文件,因此标记为不可重试。
VerifyFailed = true;
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = _verifyOperation.Error; Error = _verifyOperation.Error;