mirror of https://github.com/tuyoogame/YooAsset
refactor : build System Stability
工具类新增了FileSHA1Safely,FileMD5Safely,FileCRC32Safely等方法。pull/274/head
parent
4c619778c3
commit
a1450ee78a
|
@ -111,7 +111,7 @@ namespace YooAsset
|
|||
// 再验证文件CRC
|
||||
if (verifyLevel == EVerifyLevel.High)
|
||||
{
|
||||
string crc = HashUtility.FileCRC32(filePath);
|
||||
string crc = HashUtility.FileCRC32Safely(filePath);
|
||||
if (crc == fileCRC)
|
||||
return EVerifyResult.Succeed;
|
||||
else
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace YooAsset
|
|||
return;
|
||||
}
|
||||
|
||||
string fileHash = HashUtility.FileMD5(_manifestFilePath);
|
||||
string fileHash = HashUtility.FileMD5Safely(_manifestFilePath);
|
||||
if (fileHash != _queryCachePackageHashOp.PackageHash)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
|
|
|
@ -214,14 +214,22 @@ namespace YooAsset
|
|||
/// 获取文件的Hash值
|
||||
/// </summary>
|
||||
public static string FileSHA1(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
return StreamSHA1(fs);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件的Hash值
|
||||
/// </summary>
|
||||
public static string FileSHA1Safely(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
return FileSHA1(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
YooLogger.Exception(e);
|
||||
|
@ -266,14 +274,22 @@ namespace YooAsset
|
|||
/// 获取文件的MD5
|
||||
/// </summary>
|
||||
public static string FileMD5(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
return StreamMD5(fs);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件的MD5
|
||||
/// </summary>
|
||||
public static string FileMD5Safely(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
return FileMD5(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
YooLogger.Exception(e);
|
||||
|
@ -316,14 +332,22 @@ namespace YooAsset
|
|||
/// 获取文件的CRC32
|
||||
/// </summary>
|
||||
public static string FileCRC32(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
return StreamCRC32(fs);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件的CRC32
|
||||
/// </summary>
|
||||
public static string FileCRC32Safely(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
return FileCRC32(filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
YooLogger.Exception(e);
|
||||
|
|
Loading…
Reference in New Issue