mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-20 15:20:07 +00:00
update download system
优化资源文件下载流程。
This commit is contained in:
@@ -73,9 +73,9 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证并缓存补丁包文件
|
||||
/// 验证并缓存本地文件
|
||||
/// </summary>
|
||||
public static EVerifyResult VerifyAndCacheBundle(PatchBundle patchBundle, EVerifyLevel verifyLevel)
|
||||
public static EVerifyResult VerifyAndCacheLocalBundleFile(PatchBundle patchBundle, EVerifyLevel verifyLevel)
|
||||
{
|
||||
var verifyResult = VerifyContentInternal(patchBundle.CachedFilePath, patchBundle.FileSize, patchBundle.FileCRC, verifyLevel);
|
||||
if (verifyResult == EVerifyResult.Succeed)
|
||||
@@ -83,10 +83,41 @@ namespace YooAsset
|
||||
return verifyResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证并缓存下载文件
|
||||
/// </summary>
|
||||
public static EVerifyResult VerifyAndCacheDownloadBundleFile(PatchBundle patchBundle, EVerifyLevel verifyLevel)
|
||||
{
|
||||
string tempFilePath = patchBundle.CachedFilePath + ".temp";
|
||||
var verifyResult = VerifyContentInternal(tempFilePath, patchBundle.FileSize, patchBundle.FileCRC, verifyLevel);
|
||||
if (verifyResult == EVerifyResult.Succeed)
|
||||
{
|
||||
try
|
||||
{
|
||||
string destFilePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(destFilePath))
|
||||
File.Delete(destFilePath);
|
||||
|
||||
FileInfo fileInfo = new FileInfo(tempFilePath);
|
||||
fileInfo.MoveTo(destFilePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
verifyResult = EVerifyResult.FileMoveFailed;
|
||||
}
|
||||
|
||||
if (verifyResult == EVerifyResult.Succeed)
|
||||
{
|
||||
CacheBundle(patchBundle);
|
||||
}
|
||||
}
|
||||
return verifyResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证文件完整性
|
||||
/// </summary>
|
||||
public static EVerifyResult VerifyContentInternal(string filePath, long fileSize, string fileCRC, EVerifyLevel verifyLevel)
|
||||
private static EVerifyResult VerifyContentInternal(string filePath, long fileSize, string fileCRC, EVerifyLevel verifyLevel)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user