Update runtime

This commit is contained in:
hevinci
2022-08-03 20:51:06 +08:00
parent 195d1805e9
commit 7e6c678e91
14 changed files with 80 additions and 74 deletions
@@ -74,13 +74,13 @@ namespace YooAsset
public static DownloaderBase BeginDownload(BundleInfo bundleInfo, int failedTryAgain, int timeout = 60)
{
// 查询存在的下载器
if (_downloaderDic.TryGetValue(bundleInfo.Hash, out var downloader))
if (_downloaderDic.TryGetValue(bundleInfo.FileHash, out var downloader))
{
return downloader;
}
// 如果资源已经缓存
if (ContainsVerifyFile(bundleInfo.Hash))
if (ContainsVerifyFile(bundleInfo.FileHash))
{
var tempDownloader = new TempDownloader(bundleInfo);
return tempDownloader;
@@ -91,12 +91,12 @@ namespace YooAsset
YooLogger.Log($"Beginning to download file : {bundleInfo.FileName} URL : {bundleInfo.RemoteMainURL}");
FileUtility.CreateFileDirectory(bundleInfo.GetCacheLoadPath());
DownloaderBase newDownloader;
if (bundleInfo.SizeBytes >= _breakpointResumeFileSize)
if (bundleInfo.FileSize >= _breakpointResumeFileSize)
newDownloader = new HttpDownloader(bundleInfo);
else
newDownloader = new FileDownloader(bundleInfo);
newDownloader.SendRequest(failedTryAgain, timeout);
_downloaderDic.Add(bundleInfo.Hash, newDownloader);
_downloaderDic.Add(bundleInfo.FileHash, newDownloader);
return newDownloader;
}
}
@@ -113,11 +113,11 @@ namespace YooAsset
/// 查询是否为验证文件
/// 注意:被收录的文件完整性是绝对有效的
/// </summary>
public static bool ContainsVerifyFile(string hash)
public static bool ContainsVerifyFile(string fileHash)
{
if (_cachedHashList.ContainsKey(hash))
if (_cachedHashList.ContainsKey(fileHash))
{
string fileName = _cachedHashList[hash];
string fileName = _cachedHashList[fileHash];
string filePath = SandboxHelper.MakeCacheFilePath(fileName);
if (File.Exists(filePath))
{
@@ -125,7 +125,7 @@ namespace YooAsset
}
else
{
_cachedHashList.Remove(hash);
_cachedHashList.Remove(fileHash);
YooLogger.Error($"Cache file is missing : {fileName}");
return false;
}
@@ -139,27 +139,27 @@ namespace YooAsset
/// <summary>
/// 缓存验证过的文件
/// </summary>
public static void CacheVerifyFile(string hash, string fileName)
public static void CacheVerifyFile(string fileHash, string fileName)
{
if (_cachedHashList.ContainsKey(hash) == false)
if (_cachedHashList.ContainsKey(fileHash) == false)
{
YooLogger.Log($"Cache verify file : {fileName}");
_cachedHashList.Add(hash, fileName);
_cachedHashList.Add(fileHash, fileName);
}
}
/// <summary>
/// 验证文件完整性
/// </summary>
public static bool CheckContentIntegrity(string filePath, long size, string crc)
public static bool CheckContentIntegrity(string filePath, long fileSize, string fileCRC)
{
return CheckContentIntegrity(_verifyLevel, filePath, size, crc);
return CheckContentIntegrity(_verifyLevel, filePath, fileSize, fileCRC);
}
/// <summary>
/// 验证文件完整性
/// </summary>
public static bool CheckContentIntegrity(EVerifyLevel verifyLevel, string filePath, long size, string crc)
public static bool CheckContentIntegrity(EVerifyLevel verifyLevel, string filePath, long fileSize, string fileCRC)
{
try
{
@@ -167,15 +167,15 @@ namespace YooAsset
return false;
// 先验证文件大小
long fileSize = FileUtility.GetFileSize(filePath);
if (fileSize != size)
long size = FileUtility.GetFileSize(filePath);
if (size != fileSize)
return false;
// 再验证文件CRC
if (verifyLevel == EVerifyLevel.High)
{
string fileCRC = HashUtility.FileCRC32(filePath);
return fileCRC == crc;
string crc = HashUtility.FileCRC32(filePath);
return crc == fileCRC;
}
else
{