Update CacheSystem

pull/35/head
hevinci 2022-08-06 16:40:40 +08:00
parent a1ad7acb3d
commit 314c5cd86a
8 changed files with 23 additions and 23 deletions

View File

@ -203,7 +203,7 @@ namespace YooAsset
} }
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
{ {
if (CacheSystem.ContainsVerifyFile(_bundleInfo.FileHash)) if (CacheSystem.ContainsVerifyFile(_bundleInfo.LoadBundle))
_steps = ESteps.CheckAndCopyFile; _steps = ESteps.CheckAndCopyFile;
else else
_steps = ESteps.DownloadFromApk; _steps = ESteps.DownloadFromApk;
@ -240,7 +240,7 @@ namespace YooAsset
{ {
if (CacheSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC)) if (CacheSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC))
{ {
CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); CacheSystem.CacheVerifyFile(_bundleInfo.LoadBundle);
_steps = ESteps.CheckAndCopyFile; _steps = ESteps.CheckAndCopyFile;
} }
else else
@ -355,7 +355,7 @@ namespace YooAsset
} }
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
{ {
if (CacheSystem.ContainsVerifyFile(_bundleInfo.FileHash)) if (CacheSystem.ContainsVerifyFile(_bundleInfo.LoadBundle))
_steps = ESteps.CheckAndCopyFile; _steps = ESteps.CheckAndCopyFile;
else else
_steps = ESteps.DownloadFromApk; _steps = ESteps.DownloadFromApk;
@ -423,7 +423,7 @@ namespace YooAsset
{ {
if (CacheSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC)) if (CacheSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC))
{ {
CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); CacheSystem.CacheVerifyFile(_bundleInfo.LoadBundle);
_steps = ESteps.CheckAndCopyFile; _steps = ESteps.CheckAndCopyFile;
} }
else else

View File

@ -15,7 +15,6 @@ namespace YooAsset
{ {
_verifyLevel = verifyLevel; _verifyLevel = verifyLevel;
} }
public static void DestroyAll() public static void DestroyAll()
{ {
_cacheBundles.Clear(); _cacheBundles.Clear();
@ -49,14 +48,13 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 查询是否为验证文件 /// 查询是否为验证文件
/// 注意:被收录的文件完整性是绝对有效的 /// 注意:被收录的文件完整性是绝对有效的
/// </summary> /// </summary>
public static bool ContainsVerifyFile(string fileHash) public static bool ContainsVerifyFile(PatchBundle patchBundle)
{ {
string fileHash = patchBundle.FileHash;
if (_cachedHashList.ContainsKey(fileHash)) if (_cachedHashList.ContainsKey(fileHash))
{ {
string fileName = _cachedHashList[fileHash]; string fileName = _cachedHashList[fileHash];
@ -81,8 +79,10 @@ namespace YooAsset
/// <summary> /// <summary>
/// 缓存验证过的文件 /// 缓存验证过的文件
/// </summary> /// </summary>
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) if (_cachedHashList.ContainsKey(fileHash) == false)
{ {
YooLogger.Log($"Cache verify file : {fileName}"); YooLogger.Log($"Cache verify file : {fileName}");

View File

@ -48,7 +48,7 @@ namespace YooAsset
foreach (var patchBundle in localPatchManifest.BundleList) foreach (var patchBundle in localPatchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
@ -140,7 +140,7 @@ namespace YooAsset
if (info.Result) if (info.Result)
{ {
VerifySuccessCount++; VerifySuccessCount++;
CacheSystem.CacheVerifyFile(info.Bundle.FileHash, info.Bundle.FileName); CacheSystem.CacheVerifyFile(info.Bundle);
} }
else else
{ {
@ -173,7 +173,7 @@ namespace YooAsset
foreach (var patchBundle in localPatchManifest.BundleList) foreach (var patchBundle in localPatchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
@ -239,7 +239,7 @@ namespace YooAsset
if (result) if (result)
{ {
VerifySuccessCount++; VerifySuccessCount++;
CacheSystem.CacheVerifyFile(patchBundle.FileHash, patchBundle.FileName); CacheSystem.CacheVerifyFile(patchBundle);
} }
else else
{ {

View File

@ -76,7 +76,7 @@ namespace YooAsset
} }
// 如果资源已经缓存 // 如果资源已经缓存
if (CacheSystem.ContainsVerifyFile(bundleInfo.FileHash)) if (CacheSystem.ContainsVerifyFile(bundleInfo.LoadBundle))
{ {
var tempDownloader = new TempDownloader(bundleInfo); var tempDownloader = new TempDownloader(bundleInfo);
return tempDownloader; return tempDownloader;

View File

@ -91,7 +91,7 @@ namespace YooAsset
if (hasError == false) if (hasError == false)
{ {
_steps = ESteps.Succeed; _steps = ESteps.Succeed;
CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); CacheSystem.CacheVerifyFile(_bundleInfo.LoadBundle);
} }
else else
{ {

View File

@ -226,7 +226,7 @@ namespace YooAsset
} }
else else
{ {
CacheSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName); CacheSystem.CacheVerifyFile(_bundleInfo.LoadBundle);
_steps = ESteps.Succeed; _steps = ESteps.Succeed;
} }
} }

View File

@ -198,7 +198,7 @@ namespace YooAsset
foreach (var patchBundle in _remotePatchManifest.BundleList) foreach (var patchBundle in _remotePatchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源

View File

@ -131,7 +131,7 @@ namespace YooAsset
foreach (var patchBundle in LocalPatchManifest.BundleList) foreach (var patchBundle in LocalPatchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
@ -163,7 +163,7 @@ namespace YooAsset
foreach (var patchBundle in LocalPatchManifest.BundleList) foreach (var patchBundle in LocalPatchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
@ -233,7 +233,7 @@ namespace YooAsset
foreach (var patchBundle in checkList) foreach (var patchBundle in checkList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
@ -269,7 +269,7 @@ namespace YooAsset
continue; continue;
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
continue; continue;
// 查询DLC资源 // 查询DLC资源
@ -301,7 +301,7 @@ namespace YooAsset
continue; continue;
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
continue; continue;
downloadList.Add(patchBundle); downloadList.Add(patchBundle);
@ -377,7 +377,7 @@ namespace YooAsset
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 查询沙盒资源 // 查询沙盒资源
if (CacheSystem.ContainsVerifyFile(patchBundle.FileHash)) if (CacheSystem.ContainsVerifyFile(patchBundle))
{ {
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache); BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
return bundleInfo; return bundleInfo;