Update patch manifest

This commit is contained in:
hevinci
2022-07-25 15:46:20 +08:00
parent e5c7bbdf52
commit d0b7ae020c
10 changed files with 86 additions and 35 deletions
@@ -23,6 +23,11 @@ namespace YooAsset
/// </summary>
public string BundleName { private set; get; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName { private set; get; }
/// <summary>
/// 远端下载地址
/// </summary>
@@ -51,7 +56,7 @@ namespace YooAsset
return _patchBundle.Hash;
}
}
/// <summary>
/// 校验的CRC
/// </summary>
@@ -128,6 +133,7 @@ namespace YooAsset
_patchBundle = patchBundle;
LoadMode = loadMode;
BundleName = patchBundle.BundleName;
FileName = patchBundle.FileName;
RemoteMainURL = mainURL;
RemoteFallbackURL = fallbackURL;
EditorAssetPath = string.Empty;
@@ -137,6 +143,7 @@ namespace YooAsset
_patchBundle = patchBundle;
LoadMode = loadMode;
BundleName = patchBundle.BundleName;
FileName = patchBundle.FileName;
RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty;
EditorAssetPath = editorAssetPath;
@@ -146,6 +153,7 @@ namespace YooAsset
_patchBundle = patchBundle;
LoadMode = loadMode;
BundleName = patchBundle.BundleName;
FileName = patchBundle.FileName;
RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty;
EditorAssetPath = string.Empty;
@@ -160,7 +168,7 @@ namespace YooAsset
return string.Empty;
if (string.IsNullOrEmpty(_streamingPath))
_streamingPath = PathHelper.MakeStreamingLoadPath(_patchBundle.Hash);
_streamingPath = PathHelper.MakeStreamingLoadPath(_patchBundle.FileName);
return _streamingPath;
}
@@ -173,7 +181,7 @@ namespace YooAsset
return string.Empty;
if (string.IsNullOrEmpty(_cachePath))
_cachePath = SandboxHelper.MakeCacheFilePath(_patchBundle.Hash);
_cachePath = SandboxHelper.MakeCacheFilePath(_patchBundle.FileName);
return _cachePath;
}
@@ -391,7 +391,7 @@ namespace YooAsset
// 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性
if (weaklyUpdate)
{
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.FileName);
if (File.Exists(filePath))
_waitingList.Add(patchBundle);
else
@@ -399,7 +399,7 @@ namespace YooAsset
}
else
{
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.FileName);
if (File.Exists(filePath))
_waitingList.Add(patchBundle);
}
@@ -451,7 +451,7 @@ namespace YooAsset
private bool RunThread(PatchBundle patchBundle)
{
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.FileName);
ThreadInfo info = new ThreadInfo(filePath, patchBundle);
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), info);
}
@@ -467,7 +467,7 @@ namespace YooAsset
if (info.Result)
{
VerifySuccessCount++;
DownloadSystem.CacheVerifyFile(info.Bundle.Hash, info.Bundle.BundleName);
DownloadSystem.CacheVerifyFile(info.Bundle.Hash, info.Bundle.FileName);
}
else
{
@@ -211,7 +211,7 @@ namespace YooAsset
// 注意:通过比对文件大小做快速的文件校验!
// 注意:在初始化的时候会去做最终校验!
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.FileName);
if (File.Exists(filePath))
{
long fileSize = FileUtility.GetFileSize(filePath);
@@ -26,6 +26,11 @@ namespace YooAsset
/// </summary>
public long SizeBytes;
/// <summary>
/// 名字样式
/// </summary>
public byte NameStyle;
/// <summary>
/// 资源包的分类标签
/// </summary>
@@ -52,14 +57,55 @@ namespace YooAsset
/// </summary>
public bool IsRawFile { private set; get; }
/// <summary>
/// 文件名称
/// </summary>
public string FileName
{
get
{
if (_fileName != null)
return _fileName;
if (NameStyle == 1)
{
_fileName = Hash;
}
else if (NameStyle == 2)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
_fileName = $"{Hash}{tempFileExtension}";
}
else if (NameStyle == 3)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
_fileName = $"{tempBundleName}_{Hash}";
}
else if (NameStyle == 4)
{
string tempFileExtension = System.IO.Path.GetExtension(BundleName);
string tempBundleName = BundleName.Replace('/', '_').Replace(tempFileExtension, "");
_fileName = $"{tempBundleName}_{Hash}{tempFileExtension}";
}
else
{
throw new NotImplementedException();
}
return _fileName;
}
}
private string _fileName = null;
public PatchBundle(string bundleName, string hash, string crc, long sizeBytes, string[] tags)
public PatchBundle(string bundleName, string hash, string crc, long sizeBytes, byte nameStyle, string[] tags)
{
BundleName = bundleName;
Hash = hash;
CRC = crc;
SizeBytes = sizeBytes;
NameStyle = nameStyle;
Tags = tags;
}
@@ -102,7 +102,7 @@ namespace YooAsset
bool used = false;
foreach (var patchBundle in LocalPatchManifest.BundleList)
{
if (fileInfo.Name == patchBundle.Hash)
if (fileInfo.Name == patchBundle.FileName)
{
used = true;
break;
@@ -333,9 +333,8 @@ namespace YooAsset
}
public BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
{
// 注意:资源版本号只用于确定下载路径
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Hash);
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Hash);
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.FileName);
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.FileName);
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
return bundleInfo;
}
@@ -354,7 +353,7 @@ namespace YooAsset
public BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
{
// 注意:我们把流加载路径指定为远端下载地址
string streamingPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
string streamingPath = PathHelper.MakeStreamingLoadPath(patchBundle.FileName);
streamingPath = PathHelper.ConvertToWWWPath(streamingPath);
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, streamingPath, streamingPath);
return bundleInfo;