mirror of https://github.com/tuyoogame/YooAsset
Update download system
parent
ece1dab28b
commit
bf0f479234
|
@ -155,17 +155,24 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public static bool CheckContentIntegrity(string filePath, long size, string crc)
|
public static bool CheckContentIntegrity(string filePath, long size, string crc)
|
||||||
{
|
{
|
||||||
if (File.Exists(filePath) == false)
|
try
|
||||||
return false;
|
{
|
||||||
|
if (File.Exists(filePath) == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
// 先验证文件大小
|
// 先验证文件大小
|
||||||
long fileSize = FileUtility.GetFileSize(filePath);
|
long fileSize = FileUtility.GetFileSize(filePath);
|
||||||
if (fileSize != size)
|
if (fileSize != size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 再验证文件CRC
|
// 再验证文件CRC
|
||||||
string fileCRC = HashUtility.FileCRC32(filePath);
|
string fileCRC = HashUtility.FileCRC32(filePath);
|
||||||
return fileCRC == crc;
|
return fileCRC == crc;
|
||||||
|
}
|
||||||
|
catch(Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -332,16 +332,8 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
private void VerifyInThread(object infoObj)
|
private void VerifyInThread(object infoObj)
|
||||||
{
|
{
|
||||||
// 验证沙盒内的文件
|
|
||||||
ThreadInfo info = (ThreadInfo)infoObj;
|
ThreadInfo info = (ThreadInfo)infoObj;
|
||||||
try
|
info.Result = DownloadSystem.CheckContentIntegrity(info.FilePath, info.Bundle.SizeBytes, info.Bundle.CRC);
|
||||||
{
|
|
||||||
info.Result = DownloadSystem.CheckContentIntegrity(info.FilePath, info.Bundle.SizeBytes, info.Bundle.CRC);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
info.Result = false;
|
|
||||||
}
|
|
||||||
_syncContext.Post(VerifyCallback, info);
|
_syncContext.Post(VerifyCallback, info);
|
||||||
}
|
}
|
||||||
private void VerifyCallback(object obj)
|
private void VerifyCallback(object obj)
|
||||||
|
|
Loading…
Reference in New Issue