mirror of https://github.com/tuyoogame/YooAsset
微信小游戏,PackageVersion请求url添加_appendTimeTicks;修改unusedCache路径判断
parent
0627641845
commit
e0427d3062
|
@ -13,6 +13,7 @@ namespace YooAsset
|
|||
private static readonly List<ResourcePackage> _packages = new List<ResourcePackage>();
|
||||
|
||||
public const string DefaultPackageVersion_Key = "DefaultPackageVersion_Key";
|
||||
public const string DefaultPcakageVersion = "100000";
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经初始化
|
||||
|
|
|
@ -49,7 +49,6 @@ internal class WXFSClearUnusedBundleFilesAsync : FSClearUnusedBundleFilesOperati
|
|||
if(_fileData != null && _fileData.Length > 0 && !string.IsNullOrEmpty(_packageHash))
|
||||
{
|
||||
_steps = ESteps.VerifyFileData;
|
||||
Debug.Log($"===_packageHash==={_packageHash}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -57,8 +56,6 @@ internal class WXFSClearUnusedBundleFilesAsync : FSClearUnusedBundleFilesOperati
|
|||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to load cache package manifest file!";
|
||||
}
|
||||
|
||||
//YooLogger.Log($"Found unused cache files count : {_unusedFileTotalCount}");
|
||||
}
|
||||
|
||||
if(_steps == ESteps.VerifyFileData)
|
||||
|
@ -165,12 +162,13 @@ internal class WXFSClearUnusedBundleFilesAsync : FSClearUnusedBundleFilesOperati
|
|||
private void LoadManifestInfo()
|
||||
{
|
||||
var packageName = _fileSystem.PackageName;
|
||||
_lastPackageVersion = WX.StorageGetStringSync(YooAssets.DefaultPackageVersion_Key, "100000");
|
||||
_lastPackageVersion = WX.StorageGetStringSync(YooAssets.DefaultPackageVersion_Key, YooAssets.DefaultPcakageVersion);
|
||||
Debug.Log($"==========取出本地数据版本文件成功==={_lastPackageVersion}");
|
||||
if (!string.IsNullOrEmpty(_lastPackageVersion))
|
||||
{
|
||||
var cacheManifestHashPath = GetUnuseCachePathByBundleName(YooAssetSettingsData.GetPackageHashFileName(packageName, _lastPackageVersion));
|
||||
var cacheManifestPath = GetUnuseCachePathByBundleName(YooAssetSettingsData.GetManifestBinaryFileName(packageName, _lastPackageVersion));
|
||||
if(string.IsNullOrEmpty(cacheManifestHashPath) || string.IsNullOrEmpty(cacheManifestPath)) { return; }
|
||||
|
||||
_packageHash = _fileSystem.ReadFileText(cacheManifestHashPath);
|
||||
_fileData = _fileSystem.ReadFileData(cacheManifestPath);
|
||||
|
@ -179,8 +177,8 @@ internal class WXFSClearUnusedBundleFilesAsync : FSClearUnusedBundleFilesOperati
|
|||
|
||||
private string GetUnuseCachePathByBundleName(string fileName)
|
||||
{
|
||||
var path = $"StreamingAssets/WebGL/v{WechatFileSystemCreater.AppVersion}/{fileName}";
|
||||
return WX.GetCachePath(path);
|
||||
var filePath = $"StreamingAssets/WebGL/{fileName}";
|
||||
return WX.GetCachePath(filePath);
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -11,14 +11,16 @@ internal class WXFSRequestPackageVersionOperation : FSRequestPackageVersionOpera
|
|||
}
|
||||
|
||||
private readonly WechatFileSystem _fileSystem;
|
||||
private readonly bool _appendTimeTicks;
|
||||
private readonly int _timeout;
|
||||
private RequestWechatPackageVersionOperation _requestWebPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal WXFSRequestPackageVersionOperation(WechatFileSystem fileSystem, int timeout)
|
||||
internal WXFSRequestPackageVersionOperation(WechatFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
|
@ -34,7 +36,7 @@ internal class WXFSRequestPackageVersionOperation : FSRequestPackageVersionOpera
|
|||
{
|
||||
if (_requestWebPackageVersionOp == null)
|
||||
{
|
||||
_requestWebPackageVersionOp = new RequestWechatPackageVersionOperation(_fileSystem, _timeout);
|
||||
_requestWebPackageVersionOp = new RequestWechatPackageVersionOperation(_fileSystem, _appendTimeTicks, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageVersionOp);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ internal class RequestWechatPackageVersionOperation : AsyncOperationBase
|
|||
|
||||
private readonly WechatFileSystem _fileSystem;
|
||||
private readonly int _timeout;
|
||||
private readonly bool _appendTimeTicks;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private int _requestCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
@ -22,9 +23,10 @@ internal class RequestWechatPackageVersionOperation : AsyncOperationBase
|
|||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
public RequestWechatPackageVersionOperation(WechatFileSystem fileSystem, int timeout)
|
||||
public RequestWechatPackageVersionOperation(WechatFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
|
@ -78,11 +80,19 @@ internal class RequestWechatPackageVersionOperation : AsyncOperationBase
|
|||
|
||||
private string GetRequestURL(string fileName)
|
||||
{
|
||||
string url;
|
||||
|
||||
// 轮流返回请求地址
|
||||
if (_requestCount % 2 == 0)
|
||||
return _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||
url = _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||
else
|
||||
return _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||
url = _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||
|
||||
// 在URL末尾添加时间戳
|
||||
if (_appendTimeTicks)
|
||||
return $"{url}?{System.DateTime.UtcNow.Ticks}";
|
||||
else
|
||||
return url;
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -112,7 +112,7 @@ internal class WechatFileSystem : IFileSystem
|
|||
}
|
||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new WXFSRequestPackageVersionOperation(this, timeout);
|
||||
var operation = new WXFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -34,19 +34,17 @@ internal class FsmClearPackageCache : IStateNode
|
|||
{
|
||||
#if UNITY_WEBGL && WEIXINMINIGAME
|
||||
|
||||
//删除旧的资源清单文件和哈希文件
|
||||
if (WX.StorageHasKeySync(YooAssets.DefaultPackageVersion_Key))
|
||||
//删除旧的资源清单文件和哈希文件
|
||||
if (WX.StorageHasKeySync(YooAssets.DefaultPackageVersion_Key))
|
||||
{
|
||||
var packageName = (string)_machine.GetBlackboardValue("PackageName");
|
||||
var packageVersion = (string)_machine.GetBlackboardValue("PackageVersion");
|
||||
var lastPackageVersion = WX.StorageGetStringSync(YooAssets.DefaultPackageVersion_Key, "");
|
||||
if (lastPackageVersion != packageVersion)
|
||||
{
|
||||
var packageName = (string)_machine.GetBlackboardValue("PackageName");
|
||||
var packageVersion = (string)_machine.GetBlackboardValue("PackageVersion");
|
||||
var lastPackageVersion = WX.StorageGetStringSync(YooAssets.DefaultPackageVersion_Key, "");
|
||||
if (!string.IsNullOrEmpty(lastPackageVersion) && lastPackageVersion != packageVersion)
|
||||
{
|
||||
WX.StorageSetStringSync(YooAssets.DefaultPackageVersion_Key, packageVersion);
|
||||
Debug.Log($"==========本地数据版本文件设置成功==={packageVersion}");
|
||||
|
||||
}
|
||||
}
|
||||
WX.StorageSetStringSync(YooAssets.DefaultPackageVersion_Key, packageVersion);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
_machine.ChangeState<FsmUpdaterDone>();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue