From c0099cb90cb70433818d84abe1340e5eb0bad4f5 Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 21 Jun 2022 14:08:02 +0800 Subject: [PATCH] Update RawFileOperation.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化原生文件加载逻辑 --- .../Operations/RawFileOperation.cs | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs b/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs index 38c7b14..69376ee 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs @@ -203,7 +203,10 @@ namespace YooAsset } else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) { - _steps = ESteps.DownloadFromApk; + if (DownloadSystem.ContainsVerifyFile(_bundleInfo.Hash)) + _steps = ESteps.CheckAndCopyFile; + else + _steps = ESteps.DownloadFromApk; } else { @@ -235,7 +238,17 @@ namespace YooAsset } else { - _steps = ESteps.CheckAndCopyFile; + if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.SizeBytes, _bundleInfo.CRC)) + { + DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.BundleName); + _steps = ESteps.CheckAndCopyFile; + } + else + { + _steps = ESteps.Done; + Status = EOperationStatus.Failed; + Error = "File content verify failed !"; + } } _fileRequester.Dispose(); } @@ -342,7 +355,10 @@ namespace YooAsset } else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) { - _steps = ESteps.DownloadFromApk; + if (DownloadSystem.ContainsVerifyFile(_bundleInfo.Hash)) + _steps = ESteps.CheckAndCopyFile; + else + _steps = ESteps.DownloadFromApk; } else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache) { @@ -405,7 +421,17 @@ namespace YooAsset } else { - _steps = ESteps.CheckAndCopyFile; + if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.SizeBytes, _bundleInfo.CRC)) + { + DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.BundleName); + _steps = ESteps.CheckAndCopyFile; + } + else + { + _steps = ESteps.Done; + Status = EOperationStatus.Failed; + Error = "File content verify failed !"; + } } _fileRequester.Dispose(); }