update patch system
缓存文件验证采取分帧处理。
This commit is contained in:
@@ -14,7 +14,7 @@ namespace YooAsset
|
||||
private bool _locationToLower;
|
||||
private string _defaultHostServer;
|
||||
private string _fallbackHostServer;
|
||||
private IQueryServices _queryServices;
|
||||
public IQueryServices QueryServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
@@ -24,7 +24,7 @@ namespace YooAsset
|
||||
_locationToLower = locationToLower;
|
||||
_defaultHostServer = defaultHostServer;
|
||||
_fallbackHostServer = fallbackHostServer;
|
||||
_queryServices = queryServices;
|
||||
QueryServices = queryServices;
|
||||
|
||||
var operation = new HostPlayModeInitializationOperation(this, packageName);
|
||||
OperationSystem.StartOperation(operation);
|
||||
@@ -312,38 +312,6 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
internal List<VerifyInfo> GetVerifyInfoList(bool weaklyUpdateMode)
|
||||
{
|
||||
List<VerifyInfo> result = new List<VerifyInfo>(LocalPatchManifest.BundleList.Count);
|
||||
|
||||
// 遍历所有文件然后验证并缓存合法文件
|
||||
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
||||
|
||||
// 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性
|
||||
if (weaklyUpdateMode)
|
||||
{
|
||||
bool isBuildinFile = IsBuildinPatchBundle(patchBundle);
|
||||
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
||||
result.Add(verifyInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
bool isBuildinFile = IsBuildinPatchBundle(patchBundle);
|
||||
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
||||
result.Add(verifyInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
internal void SetLocalPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
LocalPatchManifest = patchManifest;
|
||||
@@ -351,7 +319,7 @@ namespace YooAsset
|
||||
}
|
||||
internal bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||
{
|
||||
return _queryServices.QueryStreamingAssets(patchBundle.FileName);
|
||||
return QueryServices.QueryStreamingAssets(patchBundle.FileName);
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace YooAsset
|
||||
{
|
||||
internal class OfflinePlayModeImpl : IBundleServices
|
||||
{
|
||||
private PatchManifest _appPatchManifest;
|
||||
public PatchManifest AppPatchManifest { private set; get; }
|
||||
private bool _locationToLower;
|
||||
|
||||
/// <summary>
|
||||
@@ -26,37 +26,15 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public string GetPackageVersion()
|
||||
{
|
||||
if (_appPatchManifest == null)
|
||||
if (AppPatchManifest == null)
|
||||
return string.Empty;
|
||||
return _appPatchManifest.PackageVersion;
|
||||
return AppPatchManifest.PackageVersion;
|
||||
}
|
||||
|
||||
internal List<VerifyInfo> GetVerifyInfoList()
|
||||
{
|
||||
List<VerifyInfo> result = new List<VerifyInfo>(_appPatchManifest.BundleList.Count);
|
||||
|
||||
// 遍历所有文件然后验证并缓存合法文件
|
||||
foreach (var patchBundle in _appPatchManifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
||||
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
bool isBuildinFile = true;
|
||||
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
||||
result.Add(verifyInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
_appPatchManifest = patchManifest;
|
||||
_appPatchManifest.InitAssetPathMapping(_locationToLower);
|
||||
AppPatchManifest = patchManifest;
|
||||
AppPatchManifest.InitAssetPathMapping(_locationToLower);
|
||||
}
|
||||
|
||||
#region IBundleServices接口
|
||||
@@ -84,7 +62,7 @@ namespace YooAsset
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var patchBundle = _appPatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
var patchBundle = AppPatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(patchBundle);
|
||||
}
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
@@ -93,7 +71,7 @@ namespace YooAsset
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var depends = _appPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
var depends = AppPatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var patchBundle in depends)
|
||||
{
|
||||
@@ -104,34 +82,34 @@ namespace YooAsset
|
||||
}
|
||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||
{
|
||||
return _appPatchManifest.GetAssetsInfoByTags(tags);
|
||||
return AppPatchManifest.GetAssetsInfoByTags(tags);
|
||||
}
|
||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||
{
|
||||
if (_appPatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||
if (AppPatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||
return patchAsset;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
string IBundleServices.MappingToAssetPath(string location)
|
||||
{
|
||||
return _appPatchManifest.MappingToAssetPath(location);
|
||||
return AppPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.TryMappingToAssetPath(string location)
|
||||
{
|
||||
return _appPatchManifest.TryMappingToAssetPath(location);
|
||||
return AppPatchManifest.TryMappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetPackageName()
|
||||
{
|
||||
return _appPatchManifest.PackageName;
|
||||
return AppPatchManifest.PackageName;
|
||||
}
|
||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return _appPatchManifest.IsIncludeBundleFile(fileName);
|
||||
return AppPatchManifest.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
bool IBundleServices.IsServicesValid()
|
||||
{
|
||||
return _appPatchManifest != null;
|
||||
return AppPatchManifest != null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user