mirror of https://github.com/tuyoogame/YooAsset
refactor : add ClearCacheFilesOptions define
parent
9fb7f8bbfe
commit
b843c6b0ed
|
@ -109,9 +109,9 @@ namespace YooAsset
|
||||||
var operation = new DBFSRequestPackageVersionOperation(this);
|
var operation = new DBFSRequestPackageVersionOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
return _unpackFileSystem.ClearCacheFilesAsync(manifest, clearMode, clearParam);
|
return _unpackFileSystem.ClearCacheFilesAsync(manifest, options);
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,36 +120,36 @@ namespace YooAsset
|
||||||
var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
if (options.ClearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearAllCacheBundleFilesOperation(this);
|
var operation = new ClearAllCacheBundleFilesOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
|
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, clearParam);
|
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, options.ClearParam);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearAllManifestFiles.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearAllManifestFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearAllCacheManifestFilesOperation(this);
|
var operation = new ClearAllCacheManifestFilesOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
|
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string error = $"Invalid clear mode : {clearMode}";
|
string error = $"Invalid clear mode : {options.ClearMode}";
|
||||||
var operation = new FSClearCacheFilesCompleteOperation(error);
|
var operation = new FSClearCacheFilesCompleteOperation(error);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace YooAsset
|
||||||
var operation = new DEFSRequestPackageVersionOperation(this);
|
var operation = new DEFSRequestPackageVersionOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
return operation;
|
return operation;
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace YooAsset
|
||||||
var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
return operation;
|
return operation;
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace YooAsset
|
||||||
var operation = new DWSFSRequestPackageVersionOperation(this, timeout);
|
var operation = new DWSFSRequestPackageVersionOperation(this, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
return operation;
|
return operation;
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam);
|
FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载Bundle文件
|
/// 下载Bundle文件
|
||||||
|
|
|
@ -1,6 +1,19 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
internal class ClearCacheFilesOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 清理模式
|
||||||
|
/// </summary>
|
||||||
|
public string ClearMode;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 附加参数
|
||||||
|
/// </summary>
|
||||||
|
public object ClearParam;
|
||||||
|
}
|
||||||
|
|
||||||
internal abstract class FSClearCacheFilesOperation : AsyncOperationBase
|
internal abstract class FSClearCacheFilesOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam);
|
ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options);
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||||
|
|
|
@ -15,17 +15,15 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly PlayModeImpl _impl;
|
private readonly PlayModeImpl _impl;
|
||||||
private readonly string _clearMode;
|
private readonly ClearCacheFilesOptions _options;
|
||||||
private readonly object _clearParam;
|
|
||||||
private List<IFileSystem> _cloneList;
|
private List<IFileSystem> _cloneList;
|
||||||
private FSClearCacheFilesOperation _clearCacheFilesOp;
|
private FSClearCacheFilesOperation _clearCacheFilesOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal ClearCacheFilesOperation(PlayModeImpl impl, string clearMode, object clearParam)
|
internal ClearCacheFilesOperation(PlayModeImpl impl, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_clearMode = clearMode;
|
_options = options;
|
||||||
_clearParam = clearParam;
|
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
|
@ -74,7 +72,7 @@ namespace YooAsset
|
||||||
var fileSystem = _cloneList[0];
|
var fileSystem = _cloneList[0];
|
||||||
_cloneList.RemoveAt(0);
|
_cloneList.RemoveAt(0);
|
||||||
|
|
||||||
_clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
_clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_impl.ActiveManifest, _options);
|
||||||
_clearCacheFilesOp.StartOperation();
|
_clearCacheFilesOp.StartOperation();
|
||||||
AddChildOperation(_clearCacheFilesOp);
|
AddChildOperation(_clearCacheFilesOp);
|
||||||
_steps = ESteps.CheckClearResult;
|
_steps = ESteps.CheckClearResult;
|
||||||
|
@ -102,7 +100,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override string InternalGetDesc()
|
internal override string InternalGetDesc()
|
||||||
{
|
{
|
||||||
return $"ClearMode : {_clearMode}";
|
return $"ClearMode : {_options.ClearMode}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -97,9 +97,9 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(string clearMode, object clearParam)
|
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new ClearCacheFilesOperation(this, clearMode, clearParam);
|
var operation = new ClearCacheFilesOperation(this, options);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,10 @@ namespace YooAsset
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
ClearCacheFilesOptions options = new ClearCacheFilesOptions();
|
||||||
|
options.ClearMode = clearMode.ToString();
|
||||||
|
options.ClearParam = clearParam;
|
||||||
|
var operation = _playModeImpl.ClearCacheFilesAsync(options);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +284,10 @@ namespace YooAsset
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
|
ClearCacheFilesOptions options = new ClearCacheFilesOptions();
|
||||||
|
options.ClearMode = clearMode;
|
||||||
|
options.ClearParam = clearParam;
|
||||||
|
var operation = _playModeImpl.ClearCacheFilesAsync(options);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ internal class TiktokFileSystem : IFileSystem
|
||||||
var operation = new TTFSRequestPackageVersionOperation(this, timeout);
|
var operation = new TTFSRequestPackageVersionOperation(this, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
return operation;
|
return operation;
|
||||||
|
|
|
@ -125,21 +125,21 @@ internal class WechatFileSystem : IFileSystem
|
||||||
var operation = new WXFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
var operation = new WXFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
if (options.ClearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new WXFSClearAllBundleFilesOperation(this);
|
var operation = new WXFSClearAllBundleFilesOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new WXFSClearUnusedBundleFilesAsync(this, manifest);
|
var operation = new WXFSClearUnusedBundleFilesAsync(this, manifest);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string error = $"Invalid clear mode : {clearMode}";
|
string error = $"Invalid clear mode : {options.ClearMode}";
|
||||||
var operation = new FSClearCacheFilesCompleteOperation(error);
|
var operation = new FSClearCacheFilesCompleteOperation(error);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue