Update CacheSystem
优化缓存系统代码结构
This commit is contained in:
@@ -86,7 +86,7 @@ namespace YooAsset
|
||||
TotalDownloadCount = downloadList.Count;
|
||||
foreach (var patchBundle in downloadList)
|
||||
{
|
||||
TotalDownloadBytes += patchBundle.FileSize;
|
||||
TotalDownloadBytes += patchBundle.Bundle.FileSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ namespace YooAsset
|
||||
// 下载成功
|
||||
_removeList.Add(downloader);
|
||||
CurrentDownloadCount++;
|
||||
CurrentDownloadBytes += bundleInfo.FileSize;
|
||||
CurrentDownloadBytes += bundleInfo.Bundle.FileSize;
|
||||
}
|
||||
|
||||
// 移除已经完成的下载器(无论成功或失败)
|
||||
@@ -170,7 +170,7 @@ namespace YooAsset
|
||||
var operation = DownloadSystem.BeginDownload(bundleInfo, _failedTryAgain);
|
||||
_downloaders.Add(operation);
|
||||
_downloadList.RemoveAt(index);
|
||||
OnStartDownloadFileCallback?.Invoke(bundleInfo.BundleName, bundleInfo.FileSize);
|
||||
OnStartDownloadFileCallback?.Invoke(bundleInfo.Bundle.BundleName, bundleInfo.Bundle.FileSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace YooAsset
|
||||
if (_failedList.Count > 0)
|
||||
{
|
||||
var failedDownloader = _failedList[0];
|
||||
string fileName = failedDownloader.GetBundleInfo().BundleName;
|
||||
string fileName = failedDownloader.GetBundleInfo().Bundle.BundleName;
|
||||
Error = $"Failed to download file : {fileName}";
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
|
||||
@@ -198,7 +198,7 @@ namespace YooAsset
|
||||
foreach (var patchBundle in _remotePatchManifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (CacheSystem.ContainsVerifyFile(patchBundle))
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
||||
|
||||
// 忽略APP资源
|
||||
@@ -209,16 +209,6 @@ namespace YooAsset
|
||||
continue;
|
||||
}
|
||||
|
||||
// 注意:通过比对文件大小做快速的文件校验!
|
||||
// 注意:在初始化的时候会去做最终校验!
|
||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.FileName);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
long fileSize = FileUtility.GetFileSize(filePath);
|
||||
if (fileSize == patchBundle.FileSize)
|
||||
continue;
|
||||
}
|
||||
|
||||
downloadList.Add(patchBundle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user