mirror of https://github.com/tuyoogame/YooAsset
parent
b330d26b4f
commit
ef5e1e65f9
|
@ -286,6 +286,7 @@ namespace YooAsset
|
||||||
// 文件解压
|
// 文件解压
|
||||||
if (_unpacker != null)
|
if (_unpacker != null)
|
||||||
{
|
{
|
||||||
|
_unpacker.WaitForAsyncComplete = true;
|
||||||
_unpacker.Update();
|
_unpacker.Update();
|
||||||
if (_unpacker.IsDone() == false)
|
if (_unpacker.IsDone() == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -149,6 +149,7 @@ namespace YooAsset
|
||||||
// 文件解压
|
// 文件解压
|
||||||
if (_unpacker != null)
|
if (_unpacker != null)
|
||||||
{
|
{
|
||||||
|
_unpacker.WaitForAsyncComplete = true;
|
||||||
_unpacker.Update();
|
_unpacker.Update();
|
||||||
if (_unpacker.IsDone() == false)
|
if (_unpacker.IsDone() == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -57,6 +57,25 @@ namespace YooAsset
|
||||||
_steps = ESteps.Waiting;
|
_steps = ESteps.Waiting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.Waiting)
|
||||||
|
{
|
||||||
|
if (_element.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
VerifyResult = _element.Result;
|
||||||
|
if (_element.Result == EVerifyResult.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Failed verify file : {_element.TempDataFilePath} ! ErrorCode : {_element.Result}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool BeginVerifyFileWithThread(VerifyTempElement element)
|
private bool BeginVerifyFileWithThread(VerifyTempElement element)
|
||||||
|
@ -67,23 +86,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
VerifyTempElement element = (VerifyTempElement)obj;
|
VerifyTempElement element = (VerifyTempElement)obj;
|
||||||
element.Result = CacheSystem.VerifyingTempFile(element);
|
element.Result = CacheSystem.VerifyingTempFile(element);
|
||||||
DownloadSystem.SyncContext.Post(VerifyCallback, element);
|
element.IsDone = true;
|
||||||
}
|
|
||||||
private void VerifyCallback(object obj)
|
|
||||||
{
|
|
||||||
VerifyTempElement element = (VerifyTempElement)obj;
|
|
||||||
VerifyResult = element.Result;
|
|
||||||
if (element.Result == EVerifyResult.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Failed verify file : {element.TempDataFilePath} ! ErrorCode : {element.Result}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +121,8 @@ namespace YooAsset
|
||||||
if (_steps == ESteps.VerifyFile)
|
if (_steps == ESteps.VerifyFile)
|
||||||
{
|
{
|
||||||
_element.Result = CacheSystem.VerifyingTempFile(_element);
|
_element.Result = CacheSystem.VerifyingTempFile(_element);
|
||||||
|
_element.IsDone = true;
|
||||||
|
|
||||||
VerifyResult = _element.Result;
|
VerifyResult = _element.Result;
|
||||||
if (_element.Result == EVerifyResult.Succeed)
|
if (_element.Result == EVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,6 +49,7 @@ namespace YooAsset
|
||||||
public string FileCRC { private set; get; }
|
public string FileCRC { private set; get; }
|
||||||
public long FileSize { private set; get; }
|
public long FileSize { private set; get; }
|
||||||
|
|
||||||
|
public bool IsDone = false;
|
||||||
public EVerifyResult Result;
|
public EVerifyResult Result;
|
||||||
|
|
||||||
public VerifyTempElement(string tempDataFilePath, string fileCRC, long fileSize)
|
public VerifyTempElement(string tempDataFilePath, string fileCRC, long fileSize)
|
||||||
|
|
|
@ -22,11 +22,6 @@ namespace YooAsset
|
||||||
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
||||||
private static readonly List<string> _removeList = new List<string>(100);
|
private static readonly List<string> _removeList = new List<string>(100);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 线程同步
|
|
||||||
/// </summary>
|
|
||||||
public static ThreadSyncContext SyncContext { set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义下载器的请求委托
|
/// 自定义下载器的请求委托
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -53,7 +48,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
SyncContext = new ThreadSyncContext();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -61,9 +55,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Update()
|
public static void Update()
|
||||||
{
|
{
|
||||||
if (SyncContext != null)
|
|
||||||
SyncContext.Update();
|
|
||||||
|
|
||||||
// 更新下载器
|
// 更新下载器
|
||||||
_removeList.Clear();
|
_removeList.Clear();
|
||||||
foreach (var valuePair in _downloaderDic)
|
foreach (var valuePair in _downloaderDic)
|
||||||
|
@ -94,7 +85,6 @@ namespace YooAsset
|
||||||
_downloaderDic.Clear();
|
_downloaderDic.Clear();
|
||||||
_removeList.Clear();
|
_removeList.Clear();
|
||||||
|
|
||||||
SyncContext = null;
|
|
||||||
RequestDelegate = null;
|
RequestDelegate = null;
|
||||||
CertificateHandlerInstance = null;
|
CertificateHandlerInstance = null;
|
||||||
BreakpointResumeFileSize = int.MaxValue;
|
BreakpointResumeFileSize = int.MaxValue;
|
||||||
|
|
|
@ -34,6 +34,11 @@ namespace YooAsset
|
||||||
protected float _downloadProgress = 0f;
|
protected float _downloadProgress = 0f;
|
||||||
protected ulong _downloadedBytes = 0;
|
protected ulong _downloadedBytes = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否等待异步结束
|
||||||
|
/// 警告:只能用于解压APP内部资源
|
||||||
|
/// </summary>
|
||||||
|
public bool WaitForAsyncComplete = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载进度(0f~1f)
|
/// 下载进度(0f~1f)
|
||||||
|
|
|
@ -48,6 +48,9 @@ namespace YooAsset
|
||||||
// 等待检测结果
|
// 等待检测结果
|
||||||
if (_steps == ESteps.WaitingCheckTempFile)
|
if (_steps == ESteps.WaitingCheckTempFile)
|
||||||
{
|
{
|
||||||
|
if (WaitForAsyncComplete)
|
||||||
|
_checkFileOp.Update();
|
||||||
|
|
||||||
if (_checkFileOp.IsDone == false)
|
if (_checkFileOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -220,6 +223,9 @@ namespace YooAsset
|
||||||
// 等待验证完成
|
// 等待验证完成
|
||||||
if (_steps == ESteps.WaitingVerifyTempFile)
|
if (_steps == ESteps.WaitingVerifyTempFile)
|
||||||
{
|
{
|
||||||
|
if (WaitForAsyncComplete)
|
||||||
|
_verifyFileOp.Update();
|
||||||
|
|
||||||
if (_verifyFileOp.IsDone == false)
|
if (_verifyFileOp.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue