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
|
// 再验证文件CRC
|
||||||
if (verifyLevel == EVerifyLevel.High)
|
if (verifyLevel == EVerifyLevel.High)
|
||||||
{
|
{
|
||||||
string crc = HashUtility.FileCRC32(filePath);
|
string crc = HashUtility.FileCRC32Safely(filePath);
|
||||||
if (crc == fileCRC)
|
if (crc == fileCRC)
|
||||||
return EVerifyResult.Succeed;
|
return EVerifyResult.Succeed;
|
||||||
else
|
else
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string fileHash = HashUtility.FileMD5(_manifestFilePath);
|
string fileHash = HashUtility.FileMD5Safely(_manifestFilePath);
|
||||||
if (fileHash != _queryCachePackageHashOp.PackageHash)
|
if (fileHash != _queryCachePackageHashOp.PackageHash)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
|
|
@ -214,13 +214,21 @@ namespace YooAsset
|
||||||
/// 获取文件的Hash值
|
/// 获取文件的Hash值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string FileSHA1(string filePath)
|
public static string FileSHA1(string filePath)
|
||||||
|
{
|
||||||
|
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
|
try
|
||||||
{
|
{
|
||||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
return FileSHA1(filePath);
|
||||||
{
|
|
||||||
return StreamSHA1(fs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -266,13 +274,21 @@ namespace YooAsset
|
||||||
/// 获取文件的MD5
|
/// 获取文件的MD5
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string FileMD5(string filePath)
|
public static string FileMD5(string filePath)
|
||||||
|
{
|
||||||
|
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
|
try
|
||||||
{
|
{
|
||||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
return FileMD5(filePath);
|
||||||
{
|
|
||||||
return StreamMD5(fs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -316,13 +332,21 @@ namespace YooAsset
|
||||||
/// 获取文件的CRC32
|
/// 获取文件的CRC32
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string FileCRC32(string filePath)
|
public static string FileCRC32(string filePath)
|
||||||
|
{
|
||||||
|
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
|
try
|
||||||
{
|
{
|
||||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
return FileCRC32(filePath);
|
||||||
{
|
|
||||||
return StreamCRC32(fs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue