mirror of https://github.com/tuyoogame/YooAsset
update runtime code
parent
ecb6f71f81
commit
087216b9da
|
@ -93,7 +93,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 验证缓存文件(子线程内操作)
|
||||
/// </summary>
|
||||
public static EVerifyResult VerifyingCacheFile(VerifyCacheElement element)
|
||||
public static EVerifyResult VerifyingCacheFile(VerifyCacheFileElement element)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 验证下载文件(子线程内操作)
|
||||
/// </summary>
|
||||
public static EVerifyResult VerifyingTempFile(VerifyTempElement element)
|
||||
public static EVerifyResult VerifyingTempFile(VerifyTempFileElement element)
|
||||
{
|
||||
return VerifyingInternal(element.TempDataFilePath, element.FileSize, element.FileCRC, EVerifyLevel.High);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 需要验证的元素
|
||||
/// </summary>
|
||||
public readonly List<VerifyCacheElement> VerifyElements = new List<VerifyCacheElement>(5000);
|
||||
public readonly List<VerifyCacheFileElement> VerifyElements = new List<VerifyCacheFileElement>(5000);
|
||||
|
||||
public FindCacheFilesOperation(string packageName)
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace YooAsset
|
|||
string fileRootPath = chidDirectory.FullName;
|
||||
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}";
|
||||
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
||||
VerifyCacheElement element = new VerifyCacheElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||
VerifyCacheFileElement element = new VerifyCacheFileElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||
VerifyElements.Add(element);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ namespace YooAsset
|
|||
string fileRootPath = chidDirectory.FullName;
|
||||
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}{dataFileExtension}";
|
||||
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
|
||||
VerifyCacheElement element = new VerifyCacheElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||
VerifyCacheFileElement element = new VerifyCacheFileElement(_packageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||
VerifyElements.Add(element);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace YooAsset
|
|||
{
|
||||
internal abstract class VerifyCacheFilesOperation : AsyncOperationBase
|
||||
{
|
||||
public static VerifyCacheFilesOperation CreateOperation(List<VerifyCacheElement> elements)
|
||||
public static VerifyCacheFilesOperation CreateOperation(List<VerifyCacheFileElement> elements)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
var operation = new VerifyCacheFilesWithoutThreadOperation(elements);
|
||||
|
@ -33,8 +33,8 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||
private List<VerifyCacheElement> _waitingList;
|
||||
private List<VerifyCacheElement> _verifyingList;
|
||||
private List<VerifyCacheFileElement> _waitingList;
|
||||
private List<VerifyCacheFileElement> _verifyingList;
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
private float _verifyStartTime;
|
||||
|
@ -42,7 +42,7 @@ namespace YooAsset
|
|||
private int _failedCount;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public VerifyCacheFilesWithThreadOperation(List<VerifyCacheElement> elements)
|
||||
public VerifyCacheFilesWithThreadOperation(List<VerifyCacheFileElement> elements)
|
||||
{
|
||||
_waitingList = elements;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace YooAsset
|
|||
if (_verifyMaxNum < 1)
|
||||
_verifyMaxNum = 1;
|
||||
|
||||
_verifyingList = new List<VerifyCacheElement>(_verifyMaxNum);
|
||||
_verifyingList = new List<VerifyCacheFileElement>(_verifyMaxNum);
|
||||
_steps = ESteps.UpdateVerify;
|
||||
}
|
||||
|
||||
|
@ -114,19 +114,19 @@ namespace YooAsset
|
|||
return 1f;
|
||||
return (float)(_succeedCount + _failedCount) / _verifyTotalCount;
|
||||
}
|
||||
private bool BeginVerifyFileWithThread(VerifyCacheElement element)
|
||||
private bool BeginVerifyFileWithThread(VerifyCacheFileElement element)
|
||||
{
|
||||
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), element);
|
||||
}
|
||||
private void VerifyInThread(object obj)
|
||||
{
|
||||
VerifyCacheElement element = (VerifyCacheElement)obj;
|
||||
VerifyCacheFileElement element = (VerifyCacheFileElement)obj;
|
||||
element.Result = CacheSystem.VerifyingCacheFile(element);
|
||||
_syncContext.Post(VerifyCallback, element);
|
||||
}
|
||||
private void VerifyCallback(object obj)
|
||||
{
|
||||
VerifyCacheElement element = (VerifyCacheElement)obj;
|
||||
VerifyCacheFileElement element = (VerifyCacheFileElement)obj;
|
||||
_verifyingList.Remove(element);
|
||||
|
||||
if (element.Result == EVerifyResult.Succeed)
|
||||
|
@ -158,8 +158,8 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private List<VerifyCacheElement> _waitingList;
|
||||
private List<VerifyCacheElement> _verifyingList;
|
||||
private List<VerifyCacheFileElement> _waitingList;
|
||||
private List<VerifyCacheFileElement> _verifyingList;
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
private float _verifyStartTime;
|
||||
|
@ -167,7 +167,7 @@ namespace YooAsset
|
|||
private int _failedCount;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public VerifyCacheFilesWithoutThreadOperation(List<VerifyCacheElement> elements)
|
||||
public VerifyCacheFilesWithoutThreadOperation(List<VerifyCacheFileElement> elements)
|
||||
{
|
||||
_waitingList = elements;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ namespace YooAsset
|
|||
_verifyMaxNum = fileCount;
|
||||
_verifyTotalCount = fileCount;
|
||||
|
||||
_verifyingList = new List<VerifyCacheElement>(_verifyMaxNum);
|
||||
_verifyingList = new List<VerifyCacheFileElement>(_verifyMaxNum);
|
||||
_steps = ESteps.UpdateVerify;
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ namespace YooAsset
|
|||
return 1f;
|
||||
return (float)(_succeedCount + _failedCount) / _verifyTotalCount;
|
||||
}
|
||||
private void BeginVerifyFileWithoutThread(VerifyCacheElement element)
|
||||
private void BeginVerifyFileWithoutThread(VerifyCacheFileElement element)
|
||||
{
|
||||
element.Result = CacheSystem.VerifyingCacheFile(element);
|
||||
if (element.Result == EVerifyResult.Succeed)
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace YooAsset
|
|||
{
|
||||
public EVerifyResult VerifyResult { protected set; get; }
|
||||
|
||||
public static VerifyTempFileOperation CreateOperation(VerifyTempElement element)
|
||||
public static VerifyTempFileOperation CreateOperation(VerifyTempFileElement element)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
var operation = new VerifyTempFileWithoutThreadOperation(element);
|
||||
|
@ -34,10 +34,10 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly VerifyTempElement _element;
|
||||
private readonly VerifyTempFileElement _element;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public VerifyTempFileWithThreadOperation(VerifyTempElement element)
|
||||
public VerifyTempFileWithThreadOperation(VerifyTempFileElement element)
|
||||
{
|
||||
_element = element;
|
||||
}
|
||||
|
@ -79,13 +79,13 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
private bool BeginVerifyFileWithThread(VerifyTempElement element)
|
||||
private bool BeginVerifyFileWithThread(VerifyTempFileElement element)
|
||||
{
|
||||
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), element);
|
||||
}
|
||||
private void VerifyInThread(object obj)
|
||||
{
|
||||
VerifyTempElement element = (VerifyTempElement)obj;
|
||||
VerifyTempFileElement element = (VerifyTempFileElement)obj;
|
||||
int result = (int)CacheSystem.VerifyingTempFile(element);
|
||||
element.Result = result;
|
||||
}
|
||||
|
@ -103,10 +103,10 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly VerifyTempElement _element;
|
||||
private readonly VerifyTempFileElement _element;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public VerifyTempFileWithoutThreadOperation(VerifyTempElement element)
|
||||
public VerifyTempFileWithoutThreadOperation(VerifyTempFileElement element)
|
||||
{
|
||||
_element = element;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 缓存文件验证元素
|
||||
/// </summary>
|
||||
internal class VerifyCacheElement
|
||||
internal class VerifyCacheFileElement
|
||||
{
|
||||
public string PackageName { private set; get; }
|
||||
public string CacheGUID { private set; get; }
|
||||
|
@ -17,7 +17,7 @@ namespace YooAsset
|
|||
public string DataFileCRC;
|
||||
public long DataFileSize;
|
||||
|
||||
public VerifyCacheElement(string packageName, string cacheGUID, string fileRootPath, string dataFilePath, string infoFilePath)
|
||||
public VerifyCacheFileElement(string packageName, string cacheGUID, string fileRootPath, string dataFilePath, string infoFilePath)
|
||||
{
|
||||
PackageName = packageName;
|
||||
CacheGUID = cacheGUID;
|
||||
|
@ -43,7 +43,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 下载文件验证元素
|
||||
/// </summary>
|
||||
internal class VerifyTempElement
|
||||
internal class VerifyTempFileElement
|
||||
{
|
||||
public string TempDataFilePath { private set; get; }
|
||||
public string FileCRC { private set; get; }
|
||||
|
@ -51,7 +51,7 @@ namespace YooAsset
|
|||
|
||||
public int Result = 0; // 注意:原子操作对象
|
||||
|
||||
public VerifyTempElement(string tempDataFilePath, string fileCRC, long fileSize)
|
||||
public VerifyTempFileElement(string tempDataFilePath, string fileCRC, long fileSize)
|
||||
{
|
||||
TempDataFilePath = tempDataFilePath;
|
||||
FileCRC = fileCRC;
|
||||
|
|
Loading…
Reference in New Issue