diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs index acb4b35..3ff00d2 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs @@ -69,31 +69,41 @@ namespace YooAsset /// /// 验证缓存文件(子线程内操作) /// - public static EVerifyResult VerifyingCacheFile(VerifyElement element, EVerifyLevel verifyLevel) + public static EVerifyResult VerifyingCacheFile(VerifyElement element) { try { - string infoFilePath = element.InfoFilePath; - if (File.Exists(infoFilePath) == false) - return EVerifyResult.InfoFileNotExisted; + if (InitVerifyLevel == EVerifyLevel.Low) + { + if (File.Exists(element.InfoFilePath) == false) + return EVerifyResult.InfoFileNotExisted; + if (File.Exists(element.DataFilePath) == false) + return EVerifyResult.DataFileNotExisted; + return EVerifyResult.Succeed; + } + else + { + if (File.Exists(element.InfoFilePath) == false) + return EVerifyResult.InfoFileNotExisted; - // 解析信息文件获取验证数据 - CacheFileInfo.ReadInfoFromFile(infoFilePath, out element.DataFileCRC, out element.DataFileSize); + // 解析信息文件获取验证数据 + CacheFileInfo.ReadInfoFromFile(element.InfoFilePath, out element.DataFileCRC, out element.DataFileSize); + } } catch (Exception) { return EVerifyResult.Exception; } - return VerifyingInternal(element.DataFilePath, element.DataFileSize, element.DataFileCRC, verifyLevel); + return VerifyingInternal(element.DataFilePath, element.DataFileSize, element.DataFileCRC, InitVerifyLevel); } /// /// 验证下载文件 /// - public static EVerifyResult VerifyingTempFile(PatchBundle patchBundle, EVerifyLevel verifyLevel) + public static EVerifyResult VerifyingTempFile(PatchBundle patchBundle) { - return VerifyingInternal(patchBundle.TempDataFilePath, patchBundle.FileSize, patchBundle.FileCRC, verifyLevel); + return VerifyingInternal(patchBundle.TempDataFilePath, patchBundle.FileSize, patchBundle.FileCRC, EVerifyLevel.High); } /// diff --git a/Assets/YooAsset/Runtime/CacheSystem/EVerifyLevel.cs b/Assets/YooAsset/Runtime/CacheSystem/EVerifyLevel.cs index a3e7943..ac60421 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/EVerifyLevel.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/EVerifyLevel.cs @@ -7,10 +7,15 @@ namespace YooAsset public enum EVerifyLevel { /// - /// 验证文件大小 + /// 验证文件存在 /// Low, + /// + /// 验证文件大小 + /// + Middle, + /// /// 验证文件大小和CRC /// diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/PackageVerifyOperation.cs b/Assets/YooAsset/Runtime/CacheSystem/Operations/PackageVerifyOperation.cs index 3bdcfa7..2ea948f 100644 --- a/Assets/YooAsset/Runtime/CacheSystem/Operations/PackageVerifyOperation.cs +++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/PackageVerifyOperation.cs @@ -121,7 +121,7 @@ namespace YooAsset private void VerifyInThread(object obj) { VerifyElement element = (VerifyElement)obj; - element.Result = CacheSystem.VerifyingCacheFile(element, CacheSystem.InitVerifyLevel); + element.Result = CacheSystem.VerifyingCacheFile(element); _syncContext.Post(VerifyCallback, element); } private void VerifyCallback(object obj) @@ -235,7 +235,7 @@ namespace YooAsset } private void BeginVerifyFileWithoutThread(VerifyElement element) { - element.Result = CacheSystem.VerifyingCacheFile(element, CacheSystem.InitVerifyLevel); + element.Result = CacheSystem.VerifyingCacheFile(element); if (element.Result == EVerifyResult.Succeed) { _succeedCount++; diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs index b1fc6ef..5d3a942 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs @@ -37,7 +37,7 @@ namespace YooAsset // 检测本地临时文件 if (_steps == ESteps.CheckTempFile) { - var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle, EVerifyLevel.High); + var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle); if (verifyResult == EVerifyResult.Succeed) { _steps = ESteps.CachingFile; @@ -198,7 +198,7 @@ namespace YooAsset // 验证下载文件 if (_steps == ESteps.VerifyingFile) { - var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle, EVerifyLevel.High); + var verifyResult = CacheSystem.VerifyingTempFile(_bundleInfo.Bundle); if (verifyResult == EVerifyResult.Succeed) { _steps = ESteps.CachingFile;