From 314c5cd86a93b140a492a372317c90b31bdfd98c Mon Sep 17 00:00:00 2001 From: hevinci Date: Sat, 6 Aug 2022 16:40:40 +0800 Subject: [PATCH] Update CacheSystem --- .../AssetSystem/Operations/RawFileOperation.cs | 8 ++++---- Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs | 10 +++++----- .../Runtime/CacheSystem/PatchCacheVerifier.cs | 8 ++++---- .../Runtime/DownloadSystem/DownloadSystem.cs | 2 +- .../DownloadSystem/Downloader/FileDownloader.cs | 2 +- .../DownloadSystem/Downloader/HttpDownloader.cs | 2 +- .../PatchSystem/Operations/UpdatePackageOperation.cs | 2 +- .../Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs | 12 ++++++------ 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs b/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs index f46b427..45c8957 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Operations/RawFileOperation.cs @@ -203,7 +203,7 @@ namespace YooAsset } else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) { - if (CacheSystem.ContainsVerifyFile(_bundleInfo.FileHash)) + if (CacheSystem.ContainsVerifyFile(_bundleInfo.LoadBundle)) _steps = ESteps.CheckAndCopyFile; else _steps = ESteps.DownloadFromApk; @@ -240,7 +240,7 @@ namespace YooAsset { if (CacheSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC)) { - CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); + CacheSystem.CacheVerifyFile(_bundleInfo.LoadBundle); _steps = ESteps.CheckAndCopyFile; } else @@ -355,7 +355,7 @@ namespace YooAsset } else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) { - if (CacheSystem.ContainsVerifyFile(_bundleInfo.FileHash)) + if (CacheSystem.ContainsVerifyFile(_bundleInfo.LoadBundle)) _steps = ESteps.CheckAndCopyFile; else _steps = ESteps.DownloadFromApk; @@ -423,7 +423,7 @@ namespace YooAsset { if (CacheSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC)) { - CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); + CacheSystem.CacheVerifyFile(_bundleInfo.LoadBundle); _steps = ESteps.CheckAndCopyFile; } else diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs index 904b1c7..23197c3 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs @@ -15,7 +15,6 @@ namespace YooAsset { _verifyLevel = verifyLevel; } - public static void DestroyAll() { _cacheBundles.Clear(); @@ -49,14 +48,13 @@ namespace YooAsset } - - /// /// 查询是否为验证文件 /// 注意:被收录的文件完整性是绝对有效的 /// - public static bool ContainsVerifyFile(string fileHash) + public static bool ContainsVerifyFile(PatchBundle patchBundle) { + string fileHash = patchBundle.FileHash; if (_cachedHashList.ContainsKey(fileHash)) { string fileName = _cachedHashList[fileHash]; @@ -81,8 +79,10 @@ namespace YooAsset /// /// 缓存验证过的文件 /// - public static void CacheVerifyFile(string fileHash, string fileName) + public static void CacheVerifyFile(PatchBundle patchBundle) { + string fileHash = patchBundle.FileHash; + string fileName = patchBundle.FileName; if (_cachedHashList.ContainsKey(fileHash) == false) { YooLogger.Log($"Cache verify file : {fileName}"); diff --git a/Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs b/Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs index 68ef2f5..2232fb4 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/PatchCacheVerifier.cs @@ -48,7 +48,7 @@ namespace YooAsset foreach (var patchBundle in localPatchManifest.BundleList) { // 忽略缓存文件 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) continue; // 忽略APP资源 @@ -140,7 +140,7 @@ namespace YooAsset if (info.Result) { VerifySuccessCount++; - CacheSystem.CacheVerifyFile(info.Bundle.FileHash, info.Bundle.FileName); + CacheSystem.CacheVerifyFile(info.Bundle); } else { @@ -173,7 +173,7 @@ namespace YooAsset foreach (var patchBundle in localPatchManifest.BundleList) { // 忽略缓存文件 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) continue; // 忽略APP资源 @@ -239,7 +239,7 @@ namespace YooAsset if (result) { VerifySuccessCount++; - CacheSystem.CacheVerifyFile(patchBundle.FileHash, patchBundle.FileName); + CacheSystem.CacheVerifyFile(patchBundle); } else { diff --git a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs index 142413c..f091361 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs @@ -76,7 +76,7 @@ namespace YooAsset } // 如果资源已经缓存 - if (CacheSystem.ContainsVerifyFile(bundleInfo.FileHash)) + if (CacheSystem.ContainsVerifyFile(bundleInfo.LoadBundle)) { var tempDownloader = new TempDownloader(bundleInfo); return tempDownloader; diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs index 7def45d..13442c6 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs @@ -91,7 +91,7 @@ namespace YooAsset if (hasError == false) { _steps = ESteps.Succeed; - CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); + CacheSystem.CacheVerifyFile(_bundleInfo.LoadBundle); } else { diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs index 59888e2..bbf6c39 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/HttpDownloader.cs @@ -226,7 +226,7 @@ namespace YooAsset } else { - CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); + CacheSystem.CacheVerifyFile(_bundleInfo.LoadBundle); _steps = ESteps.Succeed; } } diff --git a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs index e90ad90..5ddbf88 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/Operations/UpdatePackageOperation.cs @@ -198,7 +198,7 @@ namespace YooAsset foreach (var patchBundle in _remotePatchManifest.BundleList) { // 忽略缓存文件 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) continue; // 忽略APP资源 diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs index 1507d40..5d646d7 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs @@ -131,7 +131,7 @@ namespace YooAsset foreach (var patchBundle in LocalPatchManifest.BundleList) { // 忽略缓存文件 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) continue; // 忽略APP资源 @@ -163,7 +163,7 @@ namespace YooAsset foreach (var patchBundle in LocalPatchManifest.BundleList) { // 忽略缓存文件 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) continue; // 忽略APP资源 @@ -233,7 +233,7 @@ namespace YooAsset foreach (var patchBundle in checkList) { // 忽略缓存文件 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) continue; // 忽略APP资源 @@ -269,7 +269,7 @@ namespace YooAsset continue; // 忽略缓存文件 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) continue; // 查询DLC资源 @@ -301,7 +301,7 @@ namespace YooAsset continue; // 忽略缓存文件 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) continue; downloadList.Add(patchBundle); @@ -377,7 +377,7 @@ namespace YooAsset throw new Exception("Should never get here !"); // 查询沙盒资源 - if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) + if (CacheSystem.ContainsVerifyFile(patchBundle)) { BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache); return bundleInfo;