Update runtime
parent
195d1805e9
commit
7e6c678e91
|
@ -119,8 +119,8 @@ namespace YooAsset
|
||||||
|
|
||||||
DecryptionFileInfo fileInfo = new DecryptionFileInfo();
|
DecryptionFileInfo fileInfo = new DecryptionFileInfo();
|
||||||
fileInfo.BundleName = MainBundleInfo.BundleName;
|
fileInfo.BundleName = MainBundleInfo.BundleName;
|
||||||
fileInfo.BundleHash = MainBundleInfo.Hash;
|
fileInfo.FileHash = MainBundleInfo.FileHash;
|
||||||
fileInfo.BundleCRC = MainBundleInfo.CRC;
|
fileInfo.FileCRC = MainBundleInfo.FileCRC;
|
||||||
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(fileInfo);
|
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(fileInfo);
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
|
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
|
||||||
|
@ -169,7 +169,7 @@ namespace YooAsset
|
||||||
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||||
{
|
{
|
||||||
string cacheLoadPath = MainBundleInfo.GetCacheLoadPath();
|
string cacheLoadPath = MainBundleInfo.GetCacheLoadPath();
|
||||||
if (DownloadSystem.CheckContentIntegrity(EVerifyLevel.High, cacheLoadPath, MainBundleInfo.SizeBytes, MainBundleInfo.CRC) == false)
|
if (DownloadSystem.CheckContentIntegrity(EVerifyLevel.High, cacheLoadPath, MainBundleInfo.FileSize, MainBundleInfo.FileCRC) == false)
|
||||||
{
|
{
|
||||||
if (File.Exists(cacheLoadPath))
|
if (File.Exists(cacheLoadPath))
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace YooAsset
|
||||||
// 1. 从服务器或缓存中获取AssetBundle文件
|
// 1. 从服务器或缓存中获取AssetBundle文件
|
||||||
if (_steps == ESteps.LoadFile)
|
if (_steps == ESteps.LoadFile)
|
||||||
{
|
{
|
||||||
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_webURL, Hash128.Parse(MainBundleInfo.Hash));
|
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_webURL, Hash128.Parse(MainBundleInfo.FileHash));
|
||||||
_webRequest.SendWebRequest();
|
_webRequest.SendWebRequest();
|
||||||
_steps = ESteps.CheckFile;
|
_steps = ESteps.CheckFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
{
|
{
|
||||||
if (DownloadSystem.ContainsVerifyFile(_bundleInfo.Hash))
|
if (DownloadSystem.ContainsVerifyFile(_bundleInfo.FileHash))
|
||||||
_steps = ESteps.CheckAndCopyFile;
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
else
|
else
|
||||||
_steps = ESteps.DownloadFromApk;
|
_steps = ESteps.DownloadFromApk;
|
||||||
|
@ -238,9 +238,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.SizeBytes, _bundleInfo.CRC))
|
if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC))
|
||||||
{
|
{
|
||||||
DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.FileName);
|
DownloadSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName);
|
||||||
_steps = ESteps.CheckAndCopyFile;
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -267,7 +267,7 @@ namespace YooAsset
|
||||||
// 如果原生文件已经存在,则验证其完整性
|
// 如果原生文件已经存在,则验证其完整性
|
||||||
if (File.Exists(CopyPath))
|
if (File.Exists(CopyPath))
|
||||||
{
|
{
|
||||||
bool result = DownloadSystem.CheckContentIntegrity(CopyPath, _bundleInfo.SizeBytes, _bundleInfo.CRC);
|
bool result = DownloadSystem.CheckContentIntegrity(CopyPath, _bundleInfo.FileSize, _bundleInfo.FileCRC);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
@ -355,7 +355,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
{
|
{
|
||||||
if (DownloadSystem.ContainsVerifyFile(_bundleInfo.Hash))
|
if (DownloadSystem.ContainsVerifyFile(_bundleInfo.FileHash))
|
||||||
_steps = ESteps.CheckAndCopyFile;
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
else
|
else
|
||||||
_steps = ESteps.DownloadFromApk;
|
_steps = ESteps.DownloadFromApk;
|
||||||
|
@ -421,9 +421,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.SizeBytes, _bundleInfo.CRC))
|
if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.FileSize, _bundleInfo.FileCRC))
|
||||||
{
|
{
|
||||||
DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.FileName);
|
DownloadSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName);
|
||||||
_steps = ESteps.CheckAndCopyFile;
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -450,7 +450,7 @@ namespace YooAsset
|
||||||
// 如果原生文件已经存在,则验证其完整性
|
// 如果原生文件已经存在,则验证其完整性
|
||||||
if (File.Exists(CopyPath))
|
if (File.Exists(CopyPath))
|
||||||
{
|
{
|
||||||
bool result = DownloadSystem.CheckContentIntegrity(CopyPath, _bundleInfo.SizeBytes, _bundleInfo.CRC);
|
bool result = DownloadSystem.CheckContentIntegrity(CopyPath, _bundleInfo.FileSize, _bundleInfo.FileCRC);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
|
|
@ -74,13 +74,13 @@ namespace YooAsset
|
||||||
public static DownloaderBase BeginDownload(BundleInfo bundleInfo, int failedTryAgain, int timeout = 60)
|
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;
|
return downloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果资源已经缓存
|
// 如果资源已经缓存
|
||||||
if (ContainsVerifyFile(bundleInfo.Hash))
|
if (ContainsVerifyFile(bundleInfo.FileHash))
|
||||||
{
|
{
|
||||||
var tempDownloader = new TempDownloader(bundleInfo);
|
var tempDownloader = new TempDownloader(bundleInfo);
|
||||||
return tempDownloader;
|
return tempDownloader;
|
||||||
|
@ -91,12 +91,12 @@ namespace YooAsset
|
||||||
YooLogger.Log($"Beginning to download file : {bundleInfo.FileName} URL : {bundleInfo.RemoteMainURL}");
|
YooLogger.Log($"Beginning to download file : {bundleInfo.FileName} URL : {bundleInfo.RemoteMainURL}");
|
||||||
FileUtility.CreateFileDirectory(bundleInfo.GetCacheLoadPath());
|
FileUtility.CreateFileDirectory(bundleInfo.GetCacheLoadPath());
|
||||||
DownloaderBase newDownloader;
|
DownloaderBase newDownloader;
|
||||||
if (bundleInfo.SizeBytes >= _breakpointResumeFileSize)
|
if (bundleInfo.FileSize >= _breakpointResumeFileSize)
|
||||||
newDownloader = new HttpDownloader(bundleInfo);
|
newDownloader = new HttpDownloader(bundleInfo);
|
||||||
else
|
else
|
||||||
newDownloader = new FileDownloader(bundleInfo);
|
newDownloader = new FileDownloader(bundleInfo);
|
||||||
newDownloader.SendRequest(failedTryAgain, timeout);
|
newDownloader.SendRequest(failedTryAgain, timeout);
|
||||||
_downloaderDic.Add(bundleInfo.Hash, newDownloader);
|
_downloaderDic.Add(bundleInfo.FileHash, newDownloader);
|
||||||
return newDownloader;
|
return newDownloader;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,11 +113,11 @@ namespace YooAsset
|
||||||
/// 查询是否为验证文件
|
/// 查询是否为验证文件
|
||||||
/// 注意:被收录的文件完整性是绝对有效的
|
/// 注意:被收录的文件完整性是绝对有效的
|
||||||
/// </summary>
|
/// </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);
|
string filePath = SandboxHelper.MakeCacheFilePath(fileName);
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
|
@ -125,7 +125,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_cachedHashList.Remove(hash);
|
_cachedHashList.Remove(fileHash);
|
||||||
YooLogger.Error($"Cache file is missing : {fileName}");
|
YooLogger.Error($"Cache file is missing : {fileName}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -139,27 +139,27 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存验证过的文件
|
/// 缓存验证过的文件
|
||||||
/// </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}");
|
YooLogger.Log($"Cache verify file : {fileName}");
|
||||||
_cachedHashList.Add(hash, fileName);
|
_cachedHashList.Add(fileHash, fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证文件完整性
|
/// 验证文件完整性
|
||||||
/// </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>
|
||||||
/// 验证文件完整性
|
/// 验证文件完整性
|
||||||
/// </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
|
try
|
||||||
{
|
{
|
||||||
|
@ -167,15 +167,15 @@ namespace YooAsset
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 先验证文件大小
|
// 先验证文件大小
|
||||||
long fileSize = FileUtility.GetFileSize(filePath);
|
long size = FileUtility.GetFileSize(filePath);
|
||||||
if (fileSize != size)
|
if (size != fileSize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 再验证文件CRC
|
// 再验证文件CRC
|
||||||
if (verifyLevel == EVerifyLevel.High)
|
if (verifyLevel == EVerifyLevel.High)
|
||||||
{
|
{
|
||||||
string fileCRC = HashUtility.FileCRC32(filePath);
|
string crc = HashUtility.FileCRC32(filePath);
|
||||||
return fileCRC == crc;
|
return crc == fileCRC;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace YooAsset
|
||||||
if (hasError == false)
|
if (hasError == false)
|
||||||
{
|
{
|
||||||
// 注意:如果文件验证失败需要删除文件
|
// 注意:如果文件验证失败需要删除文件
|
||||||
if (DownloadSystem.CheckContentIntegrity(_bundleInfo.GetCacheLoadPath(), _bundleInfo.SizeBytes, _bundleInfo.CRC) == false)
|
if (DownloadSystem.CheckContentIntegrity(_bundleInfo.GetCacheLoadPath(), _bundleInfo.FileSize, _bundleInfo.FileCRC) == false)
|
||||||
{
|
{
|
||||||
hasError = true;
|
hasError = true;
|
||||||
_lastError = $"Verification failed";
|
_lastError = $"Verification failed";
|
||||||
|
@ -91,7 +91,7 @@ namespace YooAsset
|
||||||
if (hasError == false)
|
if (hasError == false)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Succeed;
|
||||||
DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.FileName);
|
DownloadSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -197,7 +197,7 @@ namespace YooAsset
|
||||||
|
|
||||||
_requestURL = GetRequestURL();
|
_requestURL = GetRequestURL();
|
||||||
_threadDownloader = new ThreadDownloader();
|
_threadDownloader = new ThreadDownloader();
|
||||||
_threadDownloader.Run(_requestURL, _bundleInfo.GetCacheLoadPath(), _bundleInfo.FileName, _bundleInfo.CRC, _bundleInfo.SizeBytes, _timeout);
|
_threadDownloader.Run(_requestURL, _bundleInfo.GetCacheLoadPath(), _bundleInfo.FileName, _bundleInfo.FileCRC, _bundleInfo.FileSize, _timeout);
|
||||||
_steps = ESteps.CheckDownload;
|
_steps = ESteps.CheckDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.FileName);
|
DownloadSystem.CacheVerifyFile(_bundleInfo.FileHash, _bundleInfo.FileName);
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Succeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace YooAsset
|
||||||
public TempDownloader(BundleInfo bundleInfo) : base(bundleInfo)
|
public TempDownloader(BundleInfo bundleInfo) : base(bundleInfo)
|
||||||
{
|
{
|
||||||
_downloadProgress = 1f;
|
_downloadProgress = 1f;
|
||||||
_downloadedBytes = (ulong)bundleInfo.SizeBytes;
|
_downloadedBytes = (ulong)bundleInfo.FileSize;
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Succeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,42 +46,42 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Hash
|
public string FileHash
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_patchBundle == null)
|
if (_patchBundle == null)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
else
|
else
|
||||||
return _patchBundle.Hash;
|
return _patchBundle.FileHash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 校验的CRC
|
/// 校验的CRC
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CRC
|
public string FileCRC
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_patchBundle == null)
|
if (_patchBundle == null)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
else
|
else
|
||||||
return _patchBundle.CRC;
|
return _patchBundle.FileCRC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件大小
|
/// 文件大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long SizeBytes
|
public long FileSize
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_patchBundle == null)
|
if (_patchBundle == null)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return _patchBundle.SizeBytes;
|
return _patchBundle.FileSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace YooAsset
|
||||||
TotalDownloadCount = downloadList.Count;
|
TotalDownloadCount = downloadList.Count;
|
||||||
foreach (var patchBundle in downloadList)
|
foreach (var patchBundle in downloadList)
|
||||||
{
|
{
|
||||||
TotalDownloadBytes += patchBundle.SizeBytes;
|
TotalDownloadBytes += patchBundle.FileSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ namespace YooAsset
|
||||||
// 下载成功
|
// 下载成功
|
||||||
_removeList.Add(downloader);
|
_removeList.Add(downloader);
|
||||||
CurrentDownloadCount++;
|
CurrentDownloadCount++;
|
||||||
CurrentDownloadBytes += bundleInfo.SizeBytes;
|
CurrentDownloadBytes += bundleInfo.FileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除已经完成的下载器(无论成功或失败)
|
// 移除已经完成的下载器(无论成功或失败)
|
||||||
|
@ -170,7 +170,7 @@ namespace YooAsset
|
||||||
var operation = DownloadSystem.BeginDownload(bundleInfo, _failedTryAgain);
|
var operation = DownloadSystem.BeginDownload(bundleInfo, _failedTryAgain);
|
||||||
_downloaders.Add(operation);
|
_downloaders.Add(operation);
|
||||||
_downloadList.RemoveAt(index);
|
_downloadList.RemoveAt(index);
|
||||||
OnStartDownloadFileCallback?.Invoke(bundleInfo.BundleName, bundleInfo.SizeBytes);
|
OnStartDownloadFileCallback?.Invoke(bundleInfo.BundleName, bundleInfo.FileSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -377,14 +377,14 @@ namespace YooAsset
|
||||||
foreach (var patchBundle in localPatchManifest.BundleList)
|
foreach (var patchBundle in localPatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (appPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (appPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ namespace YooAsset
|
||||||
private void VerifyInThread(object infoObj)
|
private void VerifyInThread(object infoObj)
|
||||||
{
|
{
|
||||||
ThreadInfo info = (ThreadInfo)infoObj;
|
ThreadInfo info = (ThreadInfo)infoObj;
|
||||||
info.Result = DownloadSystem.CheckContentIntegrity(info.FilePath, info.Bundle.SizeBytes, info.Bundle.CRC);
|
info.Result = DownloadSystem.CheckContentIntegrity(info.FilePath, info.Bundle.FileSize, info.Bundle.FileCRC);
|
||||||
_syncContext.Post(VerifyCallback, info);
|
_syncContext.Post(VerifyCallback, info);
|
||||||
}
|
}
|
||||||
private void VerifyCallback(object obj)
|
private void VerifyCallback(object obj)
|
||||||
|
@ -467,7 +467,7 @@ namespace YooAsset
|
||||||
if (info.Result)
|
if (info.Result)
|
||||||
{
|
{
|
||||||
VerifySuccessCount++;
|
VerifySuccessCount++;
|
||||||
DownloadSystem.CacheVerifyFile(info.Bundle.Hash, info.Bundle.FileName);
|
DownloadSystem.CacheVerifyFile(info.Bundle.FileHash, info.Bundle.FileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -198,14 +198,14 @@ namespace YooAsset
|
||||||
foreach (var patchBundle in _remotePatchManifest.BundleList)
|
foreach (var patchBundle in _remotePatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (_impl.AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (_impl.AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ namespace YooAsset
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
long fileSize = FileUtility.GetFileSize(filePath);
|
long fileSize = FileUtility.GetFileSize(filePath);
|
||||||
if (fileSize == patchBundle.SizeBytes)
|
if (fileSize == patchBundle.FileSize)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,20 +11,25 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BundleName;
|
public string BundleName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内容哈希值
|
||||||
|
/// </summary>
|
||||||
|
public string ContentHash;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Hash;
|
public string FileHash;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件校验码
|
/// 文件校验码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CRC;
|
public string FileCRC;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件大小(字节数)
|
/// 文件大小(字节数)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long SizeBytes;
|
public long FileSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包的分类标签
|
/// 资源包的分类标签
|
||||||
|
@ -58,12 +63,13 @@ namespace YooAsset
|
||||||
public string FileName { private set; get; }
|
public string FileName { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public PatchBundle(string bundleName, string hash, string crc, long sizeBytes, string[] tags)
|
public PatchBundle(string bundleName, string contentHash, string fileHash, string fileCRC, long fileSize, string[] tags)
|
||||||
{
|
{
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Hash = hash;
|
ContentHash = contentHash;
|
||||||
CRC = crc;
|
FileHash = fileHash;
|
||||||
SizeBytes = sizeBytes;
|
FileCRC = fileCRC;
|
||||||
|
FileSize = fileSize;
|
||||||
Tags = tags;
|
Tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,24 +107,24 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (nameStype == 1)
|
if (nameStype == 1)
|
||||||
{
|
{
|
||||||
FileName = Hash;
|
FileName = FileHash;
|
||||||
}
|
}
|
||||||
else if (nameStype == 2)
|
else if (nameStype == 2)
|
||||||
{
|
{
|
||||||
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
|
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
|
||||||
FileName = $"{Hash}{tempFileExtension}";
|
FileName = $"{FileHash}{tempFileExtension}";
|
||||||
}
|
}
|
||||||
else if (nameStype == 3)
|
else if (nameStype == 3)
|
||||||
{
|
{
|
||||||
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
|
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
|
||||||
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
|
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
|
||||||
FileName = $"{tempBundleName}_{Hash}";
|
FileName = $"{tempBundleName}_{FileHash}";
|
||||||
}
|
}
|
||||||
else if (nameStype == 4)
|
else if (nameStype == 4)
|
||||||
{
|
{
|
||||||
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
|
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
|
||||||
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
|
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
|
||||||
FileName = $"{tempBundleName}_{Hash}{tempFileExtension}";
|
FileName = $"{tempBundleName}_{FileHash}{tempFileExtension}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -131,14 +131,14 @@ namespace YooAsset
|
||||||
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,14 +163,14 @@ namespace YooAsset
|
||||||
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,14 +233,14 @@ namespace YooAsset
|
||||||
foreach (var patchBundle in checkList)
|
foreach (var patchBundle in checkList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 忽略APP资源
|
// 忽略APP资源
|
||||||
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
// 注意:如果是APP资源并且哈希值相同,则不需要下载
|
||||||
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ namespace YooAsset
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 查询DLC资源
|
// 查询DLC资源
|
||||||
|
@ -301,7 +301,7 @@ namespace YooAsset
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
downloadList.Add(patchBundle);
|
downloadList.Add(patchBundle);
|
||||||
|
@ -377,7 +377,7 @@ namespace YooAsset
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 查询沙盒资源
|
// 查询沙盒资源
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
|
@ -386,7 +386,7 @@ namespace YooAsset
|
||||||
// 查询APP资源
|
// 查询APP资源
|
||||||
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
|
|
|
@ -4,8 +4,8 @@ namespace YooAsset
|
||||||
public struct DecryptionFileInfo
|
public struct DecryptionFileInfo
|
||||||
{
|
{
|
||||||
public string BundleName;
|
public string BundleName;
|
||||||
public string BundleHash;
|
public string FileHash;
|
||||||
public string BundleCRC;
|
public string FileCRC;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IDecryptionServices
|
public interface IDecryptionServices
|
||||||
|
|
Loading…
Reference in New Issue