Update cache system
This commit is contained in:
@@ -10,7 +10,7 @@ namespace YooAsset
|
||||
internal sealed class FileDownloader : DownloaderBase
|
||||
{
|
||||
private UnityWebRequest _webRequest;
|
||||
private bool _breakDownload;
|
||||
private bool _breakResume;
|
||||
|
||||
// 重置变量
|
||||
private bool _isAbort = false;
|
||||
@@ -19,9 +19,9 @@ namespace YooAsset
|
||||
private float _tryAgainTimer;
|
||||
|
||||
|
||||
public FileDownloader(BundleInfo bundleInfo, bool breakDownload) : base(bundleInfo)
|
||||
public FileDownloader(BundleInfo bundleInfo, bool breakResume) : base(bundleInfo)
|
||||
{
|
||||
_breakDownload = breakDownload;
|
||||
_breakResume = breakResume;
|
||||
}
|
||||
public override void Update()
|
||||
{
|
||||
@@ -33,12 +33,19 @@ namespace YooAsset
|
||||
// 检测本地文件
|
||||
if (_steps == ESteps.CheckLocalFile)
|
||||
{
|
||||
if (CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High))
|
||||
var verifyResult = CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High);
|
||||
if (verifyResult == EVerifyResult.Succeed)
|
||||
{
|
||||
_steps = ESteps.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(verifyResult == EVerifyResult.FileOverflow)
|
||||
{
|
||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||
if (File.Exists(cacheFilePath))
|
||||
File.Delete(cacheFilePath);
|
||||
}
|
||||
_steps = ESteps.CreateDownload;
|
||||
}
|
||||
}
|
||||
@@ -57,7 +64,7 @@ namespace YooAsset
|
||||
_tryAgainTimer = 0f;
|
||||
|
||||
// 是否开启断点续传下载
|
||||
if (_breakDownload)
|
||||
if (_breakResume)
|
||||
{
|
||||
long fileLength = -1;
|
||||
if (File.Exists(fileSavePath))
|
||||
@@ -121,7 +128,8 @@ namespace YooAsset
|
||||
// 检查文件完整性
|
||||
if (hasError == false)
|
||||
{
|
||||
if (CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High) == false)
|
||||
var verifyResult = CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High);
|
||||
if (verifyResult != EVerifyResult.Succeed)
|
||||
{
|
||||
hasError = true;
|
||||
_lastError = $"Verify bundle content failed : {_bundleInfo.Bundle.FileName}";
|
||||
@@ -137,7 +145,7 @@ namespace YooAsset
|
||||
if (hasError)
|
||||
{
|
||||
// 注意:非断点续传下载失败后删除文件
|
||||
if (_breakDownload == false)
|
||||
if (_breakResume == false)
|
||||
{
|
||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||
if (File.Exists(cacheFilePath))
|
||||
|
||||
@@ -171,12 +171,19 @@ namespace YooAsset
|
||||
// 检测本地文件
|
||||
if (_steps == ESteps.CheckLocalFile)
|
||||
{
|
||||
if (CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High))
|
||||
var verifyResult = CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High);
|
||||
if (verifyResult == EVerifyResult.Succeed)
|
||||
{
|
||||
_steps = ESteps.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verifyResult == EVerifyResult.FileOverflow)
|
||||
{
|
||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||
if (File.Exists(cacheFilePath))
|
||||
File.Delete(cacheFilePath);
|
||||
}
|
||||
_steps = ESteps.CreateDownload;
|
||||
}
|
||||
}
|
||||
@@ -215,7 +222,8 @@ namespace YooAsset
|
||||
// 检查文件完整性
|
||||
if (hasError == false)
|
||||
{
|
||||
if (CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High) == false)
|
||||
var verifyResult = CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High);
|
||||
if (verifyResult != EVerifyResult.Succeed)
|
||||
{
|
||||
hasError = true;
|
||||
_lastError = $"Verify bundle content failed : {_bundleInfo.Bundle.FileName}";
|
||||
|
||||
Reference in New Issue
Block a user