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
@@ -46,42 +46,42 @@ namespace YooAsset
/// <summary>
/// 文件哈希值
/// </summary>
public string Hash
public string FileHash
{
get
{
if (_patchBundle == null)
return string.Empty;
else
return _patchBundle.Hash;
return _patchBundle.FileHash;
}
}
/// <summary>
/// 校验的CRC
/// </summary>
public string CRC
public string FileCRC
{
get
{
if (_patchBundle == null)
return string.Empty;
else
return _patchBundle.CRC;
return _patchBundle.FileCRC;
}
}
/// <summary>
/// 文件大小
/// </summary>
public long SizeBytes
public long FileSize
{
get
{
if (_patchBundle == null)
return 0;
else
return _patchBundle.SizeBytes;
return _patchBundle.FileSize;
}
}
@@ -86,7 +86,7 @@ namespace YooAsset
TotalDownloadCount = downloadList.Count;
foreach (var patchBundle in downloadList)
{
TotalDownloadBytes += patchBundle.SizeBytes;
TotalDownloadBytes += patchBundle.FileSize;
}
}
}
@@ -138,7 +138,7 @@ namespace YooAsset
// 下载成功
_removeList.Add(downloader);
CurrentDownloadCount++;
CurrentDownloadBytes += bundleInfo.SizeBytes;
CurrentDownloadBytes += bundleInfo.FileSize;
}
// 移除已经完成的下载器(无论成功或失败)
@@ -170,7 +170,7 @@ namespace YooAsset
var operation = DownloadSystem.BeginDownload(bundleInfo, _failedTryAgain);
_downloaders.Add(operation);
_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)
{
// 忽略缓存文件
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
continue;
// 忽略APP资源
// 注意:如果是APP资源并且哈希值相同,则不需要下载
if (appPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
continue;
}
@@ -458,7 +458,7 @@ namespace YooAsset
private void VerifyInThread(object 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);
}
private void VerifyCallback(object obj)
@@ -467,7 +467,7 @@ namespace YooAsset
if (info.Result)
{
VerifySuccessCount++;
DownloadSystem.CacheVerifyFile(info.Bundle.Hash, info.Bundle.FileName);
DownloadSystem.CacheVerifyFile(info.Bundle.FileHash, info.Bundle.FileName);
}
else
{
@@ -198,14 +198,14 @@ namespace YooAsset
foreach (var patchBundle in _remotePatchManifest.BundleList)
{
// 忽略缓存文件
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
continue;
// 忽略APP资源
// 注意:如果是APP资源并且哈希值相同,则不需要下载
if (_impl.AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
continue;
}
@@ -215,7 +215,7 @@ namespace YooAsset
if (File.Exists(filePath))
{
long fileSize = FileUtility.GetFileSize(filePath);
if (fileSize == patchBundle.SizeBytes)
if (fileSize == patchBundle.FileSize)
continue;
}
@@ -11,20 +11,25 @@ namespace YooAsset
/// </summary>
public string BundleName;
/// <summary>
/// 内容哈希值
/// </summary>
public string ContentHash;
/// <summary>
/// 文件哈希值
/// </summary>
public string Hash;
public string FileHash;
/// <summary>
/// 文件校验码
/// </summary>
public string CRC;
public string FileCRC;
/// <summary>
/// 文件大小(字节数)
/// </summary>
public long SizeBytes;
public long FileSize;
/// <summary>
/// 资源包的分类标签
@@ -58,12 +63,13 @@ namespace YooAsset
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;
Hash = hash;
CRC = crc;
SizeBytes = sizeBytes;
ContentHash = contentHash;
FileHash = fileHash;
FileCRC = fileCRC;
FileSize = fileSize;
Tags = tags;
}
@@ -101,24 +107,24 @@ namespace YooAsset
{
if (nameStype == 1)
{
FileName = Hash;
FileName = FileHash;
}
else if (nameStype == 2)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
FileName = $"{Hash}{tempFileExtension}";
FileName = $"{FileHash}{tempFileExtension}";
}
else if (nameStype == 3)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
FileName = $"{tempBundleName}_{Hash}";
FileName = $"{tempBundleName}_{FileHash}";
}
else if (nameStype == 4)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
FileName = $"{tempBundleName}_{Hash}{tempFileExtension}";
FileName = $"{tempBundleName}_{FileHash}{tempFileExtension}";
}
else
{
@@ -131,14 +131,14 @@ namespace YooAsset
foreach (var patchBundle in LocalPatchManifest.BundleList)
{
// 忽略缓存文件
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
continue;
// 忽略APP资源
// 注意:如果是APP资源并且哈希值相同,则不需要下载
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
continue;
}
@@ -163,14 +163,14 @@ namespace YooAsset
foreach (var patchBundle in LocalPatchManifest.BundleList)
{
// 忽略缓存文件
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
continue;
// 忽略APP资源
// 注意:如果是APP资源并且哈希值相同,则不需要下载
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
continue;
}
@@ -233,14 +233,14 @@ namespace YooAsset
foreach (var patchBundle in checkList)
{
// 忽略缓存文件
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
continue;
// 忽略APP资源
// 注意:如果是APP资源并且哈希值相同,则不需要下载
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
if (appPatchBundle.IsBuildin && appPatchBundle.FileHash == patchBundle.FileHash)
continue;
}
@@ -269,7 +269,7 @@ namespace YooAsset
continue;
// 忽略缓存文件
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
continue;
// 查询DLC资源
@@ -301,7 +301,7 @@ namespace YooAsset
continue;
// 忽略缓存文件
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
if (DownloadSystem.ContainsVerifyFile(patchBundle.FileHash))
continue;
downloadList.Add(patchBundle);
@@ -377,7 +377,7 @@ namespace YooAsset
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);
return bundleInfo;
@@ -386,7 +386,7 @@ namespace YooAsset
// 查询APP资源
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);
return bundleInfo;