mirror of https://github.com/tuyoogame/YooAsset
fix #402
parent
14ea408fec
commit
c614ba4705
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal sealed class ClearAllCacheFilesOperation : FSClearAllBundleFilesOperation
|
internal sealed class ClearAllCacheFilesOperation : FSClearCacheBundleFilesOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class ClearCacheFilesByTagsOperaiton : FSClearCacheBundleFilesOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
CheckArgs,
|
||||||
|
GetTagsCacheFiles,
|
||||||
|
ClearTagsCacheFiles,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly ICacheSystem _cacheSystem;
|
||||||
|
private readonly PackageManifest _manifest;
|
||||||
|
private readonly object _clearParam;
|
||||||
|
private string[] _tags;
|
||||||
|
private List<string> _clearBundleGUIDs;
|
||||||
|
private int _clearFileTotalCount = 0;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
internal ClearCacheFilesByTagsOperaiton(ICacheSystem cacheSystem, PackageManifest manifest, object clearParam)
|
||||||
|
{
|
||||||
|
_cacheSystem = cacheSystem;
|
||||||
|
_manifest = manifest;
|
||||||
|
_clearParam = clearParam;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckArgs;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckArgs)
|
||||||
|
{
|
||||||
|
if (_clearParam == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Clear param is null !";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_clearParam is string)
|
||||||
|
{
|
||||||
|
_tags = new string[] { _clearParam as string };
|
||||||
|
}
|
||||||
|
else if (_clearParam is List<string>)
|
||||||
|
{
|
||||||
|
var tempList = _clearParam as List<string>;
|
||||||
|
_tags = tempList.ToArray();
|
||||||
|
}
|
||||||
|
else if (_clearParam is string[])
|
||||||
|
{
|
||||||
|
_tags = _clearParam as string[];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Invalid clear param : {_clearParam.GetType().FullName}";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.GetTagsCacheFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.GetTagsCacheFiles)
|
||||||
|
{
|
||||||
|
_clearBundleGUIDs = GetTagsBundleGUIDs();
|
||||||
|
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
||||||
|
_steps = ESteps.ClearTagsCacheFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.ClearTagsCacheFiles)
|
||||||
|
{
|
||||||
|
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
string bundleGUID = _clearBundleGUIDs[i];
|
||||||
|
_cacheSystem.DeleteCacheFile(bundleGUID);
|
||||||
|
_clearBundleGUIDs.RemoveAt(i);
|
||||||
|
if (OperationSystem.IsBusy)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_clearFileTotalCount == 0)
|
||||||
|
Progress = 1.0f;
|
||||||
|
else
|
||||||
|
Progress = 1.0f - (_clearBundleGUIDs.Count / _clearFileTotalCount);
|
||||||
|
|
||||||
|
if (_clearBundleGUIDs.Count == 0)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private List<string> GetTagsBundleGUIDs()
|
||||||
|
{
|
||||||
|
var allBundleGUIDs = _cacheSystem.GetAllCachedBundleGUIDs();
|
||||||
|
List<string> result = new List<string>(allBundleGUIDs.Count);
|
||||||
|
foreach (var bundleGUID in allBundleGUIDs)
|
||||||
|
{
|
||||||
|
if (_manifest.TryGetPackageBundleByBundleGUID(bundleGUID, out PackageBundle bundle))
|
||||||
|
{
|
||||||
|
if (bundle.HasTag(_tags))
|
||||||
|
{
|
||||||
|
result.Add(bundleGUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 4f25029d71d0d8c4dad70987bda364bf
|
guid: c42345c14a903274fb160a813ee174dc
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal sealed class ClearUnusedCacheFilesOperation : FSClearUnusedBundleFilesOperation
|
internal sealed class ClearUnusedCacheFilesOperation : FSClearCacheBundleFilesOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
|
|
@ -97,13 +97,9 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
public virtual FSClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
||||||
{
|
{
|
||||||
return _unpackFileSystem.ClearAllBundleFilesAsync();
|
return _unpackFileSystem.ClearCacheBundleFilesAsync(manifest, clearMode, clearParam);
|
||||||
}
|
|
||||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest)
|
|
||||||
{
|
|
||||||
return _unpackFileSystem.ClearUnusedBundleFilesAsync(manifest);
|
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,17 +111,33 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
public virtual FSClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
||||||
{
|
{
|
||||||
var operation = new ClearAllCacheFilesOperation(this);
|
if(clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
{
|
||||||
return operation;
|
var operation = new ClearAllCacheFilesOperation(this);
|
||||||
}
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest)
|
return operation;
|
||||||
{
|
}
|
||||||
var operation = new ClearUnusedCacheFilesOperation(this, manifest);
|
else if(clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
{
|
||||||
return operation;
|
var operation = new ClearUnusedCacheFilesOperation(this, manifest);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if(clearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
|
||||||
|
{
|
||||||
|
var operation = new ClearCacheFilesByTagsOperaiton(this, manifest, clearParam);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string error = $"Invalid clear mode : {clearMode}";
|
||||||
|
var operation = new FSClearCacheBundleFilesCompleteOperation(error);
|
||||||
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,15 +69,9 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
public virtual FSClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
||||||
{
|
{
|
||||||
var operation = new FSClearAllBundleFilesCompleteOperation();
|
var operation = new FSClearCacheBundleFilesCompleteOperation(null);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest)
|
|
||||||
{
|
|
||||||
var operation = new FSClearUnusedBundleFilesCompleteOperation();
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,15 +71,9 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
public virtual FSClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
||||||
{
|
{
|
||||||
var operation = new FSClearAllBundleFilesCompleteOperation();
|
var operation = new FSClearCacheBundleFilesCompleteOperation(null);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest)
|
|
||||||
{
|
|
||||||
var operation = new FSClearUnusedBundleFilesCompleteOperation();
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,15 +80,9 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
public virtual FSClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
||||||
{
|
{
|
||||||
var operation = new FSClearAllBundleFilesCompleteOperation();
|
var operation = new FSClearCacheBundleFilesCompleteOperation(null);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest)
|
|
||||||
{
|
|
||||||
var operation = new FSClearUnusedBundleFilesCompleteOperation();
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件清理方式
|
||||||
|
/// </summary>
|
||||||
|
public enum EFileClearMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllBundleFiles = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理未在使用的文件
|
||||||
|
/// </summary>
|
||||||
|
ClearUnusedBundleFiles = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理指定标签的文件
|
||||||
|
/// 说明:需要指定参数,可选:string, string[], List<string>
|
||||||
|
/// </summary>
|
||||||
|
ClearBundleFilesByTags = 3,
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: e9fe9171073a87746a7393f7d1fcb924
|
guid: 2930435fc2ba91c4ba511260b9d119d3
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -35,14 +35,9 @@ namespace YooAsset
|
||||||
FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout);
|
FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空所有的文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FSClearAllBundleFilesOperation ClearAllBundleFilesAsync();
|
FSClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(PackageManifest manifest, string clearMode, object clearParam);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清空未使用的文件
|
|
||||||
/// </summary>
|
|
||||||
FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载远端文件
|
/// 下载远端文件
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
internal abstract class FSClearAllBundleFilesOperation : AsyncOperationBase
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
internal sealed class FSClearAllBundleFilesCompleteOperation : FSClearAllBundleFilesOperation
|
|
||||||
{
|
|
||||||
internal FSClearAllBundleFilesCompleteOperation()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
internal override void InternalOnStart()
|
|
||||||
{
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
internal override void InternalOnUpdate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal abstract class FSClearCacheBundleFilesOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class FSClearCacheBundleFilesCompleteOperation : FSClearCacheBundleFilesOperation
|
||||||
|
{
|
||||||
|
private readonly string _error;
|
||||||
|
|
||||||
|
internal FSClearCacheBundleFilesCompleteOperation(string error)
|
||||||
|
{
|
||||||
|
_error = error;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_error))
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 39028a4006030f1469b636b0c8b3805a
|
guid: b39545a4da23ce34abdf8da069198426
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
internal abstract class FSClearUnusedBundleFilesOperation : AsyncOperationBase
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
internal sealed class FSClearUnusedBundleFilesCompleteOperation : FSClearUnusedBundleFilesOperation
|
|
||||||
{
|
|
||||||
internal FSClearUnusedBundleFilesCompleteOperation()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
internal override void InternalOnStart()
|
|
||||||
{
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
internal override void InternalOnUpdate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -29,14 +29,9 @@ namespace YooAsset
|
||||||
PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout);
|
PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空所有文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClearAllBundleFilesOperation ClearAllBundleFilesAsync();
|
ClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(string clearMode, object clearParam);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清空未使用的文件
|
|
||||||
/// </summary>
|
|
||||||
ClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync();
|
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
public abstract class ClearCacheBundleFilesOperation : AsyncOperationBase
|
||||||
/// 清理所有文件
|
|
||||||
/// </summary>
|
|
||||||
public abstract class ClearAllBundleFilesOperation : AsyncOperationBase
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal sealed class ClearAllBundleFilesImplOperation : ClearAllBundleFilesOperation
|
internal sealed class ClearCacheBundleFilesImplOperation : ClearCacheBundleFilesOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -22,17 +19,21 @@ namespace YooAsset
|
||||||
private readonly IFileSystem _fileSystemA;
|
private readonly IFileSystem _fileSystemA;
|
||||||
private readonly IFileSystem _fileSystemB;
|
private readonly IFileSystem _fileSystemB;
|
||||||
private readonly IFileSystem _fileSystemC;
|
private readonly IFileSystem _fileSystemC;
|
||||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpA;
|
private readonly string _clearMode;
|
||||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpB;
|
private readonly object _clearParam;
|
||||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpC;
|
private FSClearCacheBundleFilesOperation _clearCacheBundleFilesOpA;
|
||||||
|
private FSClearCacheBundleFilesOperation _clearCacheBundleFilesOpB;
|
||||||
|
private FSClearCacheBundleFilesOperation _clearCacheBundleFilesOpC;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal ClearAllBundleFilesImplOperation(IPlayMode impl, IFileSystem fileSystemA, IFileSystem fileSystemB, IFileSystem fileSystemC)
|
internal ClearCacheBundleFilesImplOperation(IPlayMode impl, IFileSystem fileSystemA, IFileSystem fileSystemB, IFileSystem fileSystemC, string clearMode, object clearParam)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_fileSystemA = fileSystemA;
|
_fileSystemA = fileSystemA;
|
||||||
_fileSystemB = fileSystemB;
|
_fileSystemB = fileSystemB;
|
||||||
_fileSystemC = fileSystemC;
|
_fileSystemC = fileSystemC;
|
||||||
|
_clearMode = clearMode;
|
||||||
|
_clearParam = clearParam;
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
|
@ -51,14 +52,14 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_clearAllBundleFilesOpA == null)
|
if (_clearCacheBundleFilesOpA == null)
|
||||||
_clearAllBundleFilesOpA = _fileSystemA.ClearAllBundleFilesAsync();
|
_clearCacheBundleFilesOpA = _fileSystemA.ClearCacheBundleFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||||
|
|
||||||
Progress = _clearAllBundleFilesOpA.Progress;
|
Progress = _clearCacheBundleFilesOpA.Progress;
|
||||||
if (_clearAllBundleFilesOpA.IsDone == false)
|
if (_clearCacheBundleFilesOpA.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_clearAllBundleFilesOpA.Status == EOperationStatus.Succeed)
|
if (_clearCacheBundleFilesOpA.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.ClearFileSystemB;
|
_steps = ESteps.ClearFileSystemB;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +67,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _clearAllBundleFilesOpA.Error;
|
Error = _clearCacheBundleFilesOpA.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,14 +79,14 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_clearAllBundleFilesOpB == null)
|
if (_clearCacheBundleFilesOpB == null)
|
||||||
_clearAllBundleFilesOpB = _fileSystemB.ClearAllBundleFilesAsync();
|
_clearCacheBundleFilesOpB = _fileSystemB.ClearCacheBundleFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||||
|
|
||||||
Progress = _clearAllBundleFilesOpB.Progress;
|
Progress = _clearCacheBundleFilesOpB.Progress;
|
||||||
if (_clearAllBundleFilesOpB.IsDone == false)
|
if (_clearCacheBundleFilesOpB.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_clearAllBundleFilesOpB.Status == EOperationStatus.Succeed)
|
if (_clearCacheBundleFilesOpB.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.ClearFileSystemC;
|
_steps = ESteps.ClearFileSystemC;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +94,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _clearAllBundleFilesOpB.Error;
|
Error = _clearCacheBundleFilesOpB.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,14 +107,14 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_clearAllBundleFilesOpC == null)
|
if (_clearCacheBundleFilesOpC == null)
|
||||||
_clearAllBundleFilesOpC = _fileSystemC.ClearAllBundleFilesAsync();
|
_clearCacheBundleFilesOpC = _fileSystemC.ClearCacheBundleFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||||
|
|
||||||
Progress = _clearAllBundleFilesOpC.Progress;
|
Progress = _clearCacheBundleFilesOpC.Progress;
|
||||||
if (_clearAllBundleFilesOpC.IsDone == false)
|
if (_clearCacheBundleFilesOpC.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_clearAllBundleFilesOpC.Status == EOperationStatus.Succeed)
|
if (_clearCacheBundleFilesOpC.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
|
@ -122,7 +123,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _clearAllBundleFilesOpC.Error;
|
Error = _clearCacheBundleFilesOpC.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 857423cdfd4f9184eab094be01c62480
|
guid: 37b4e645f7a679f4fa978c55329ee01a
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -1,131 +0,0 @@
|
||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 清理未使用的文件
|
|
||||||
/// </summary>
|
|
||||||
public abstract class ClearUnusedBundleFilesOperation : AsyncOperationBase
|
|
||||||
{
|
|
||||||
}
|
|
||||||
internal sealed class ClearUnusedBundleFilesImplOperation : ClearUnusedBundleFilesOperation
|
|
||||||
{
|
|
||||||
private enum ESteps
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
ClearFileSystemA,
|
|
||||||
ClearFileSystemB,
|
|
||||||
ClearFileSystemC,
|
|
||||||
Done,
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly IPlayMode _impl;
|
|
||||||
private readonly IFileSystem _fileSystemA;
|
|
||||||
private readonly IFileSystem _fileSystemB;
|
|
||||||
private readonly IFileSystem _fileSystemC;
|
|
||||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOpA;
|
|
||||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOpB;
|
|
||||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOpC;
|
|
||||||
private ESteps _steps = ESteps.None;
|
|
||||||
|
|
||||||
internal ClearUnusedBundleFilesImplOperation(IPlayMode impl, IFileSystem fileSystemA, IFileSystem fileSystemB, IFileSystem fileSystemC)
|
|
||||||
{
|
|
||||||
_impl = impl;
|
|
||||||
_fileSystemA = fileSystemA;
|
|
||||||
_fileSystemB = fileSystemB;
|
|
||||||
_fileSystemC = fileSystemC;
|
|
||||||
}
|
|
||||||
internal override void InternalOnStart()
|
|
||||||
{
|
|
||||||
_steps = ESteps.ClearFileSystemA;
|
|
||||||
}
|
|
||||||
internal override void InternalOnUpdate()
|
|
||||||
{
|
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_steps == ESteps.ClearFileSystemA)
|
|
||||||
{
|
|
||||||
if (_fileSystemA == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.ClearFileSystemB;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_clearUnusedBundleFilesOpA == null)
|
|
||||||
_clearUnusedBundleFilesOpA = _fileSystemA.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
|
||||||
|
|
||||||
Progress = _clearUnusedBundleFilesOpA.Progress;
|
|
||||||
if (_clearUnusedBundleFilesOpA.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_clearUnusedBundleFilesOpA.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.ClearFileSystemB;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _clearUnusedBundleFilesOpA.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.ClearFileSystemB)
|
|
||||||
{
|
|
||||||
if (_fileSystemB == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.ClearFileSystemC;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_clearUnusedBundleFilesOpB == null)
|
|
||||||
_clearUnusedBundleFilesOpB = _fileSystemB.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
|
||||||
|
|
||||||
Progress = _clearUnusedBundleFilesOpB.Progress;
|
|
||||||
if (_clearUnusedBundleFilesOpB.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_clearUnusedBundleFilesOpB.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.ClearFileSystemC;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _clearUnusedBundleFilesOpB.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.ClearFileSystemC)
|
|
||||||
{
|
|
||||||
if (_fileSystemC == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_clearUnusedBundleFilesOpC == null)
|
|
||||||
_clearUnusedBundleFilesOpC = _fileSystemC.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
|
||||||
|
|
||||||
Progress = _clearUnusedBundleFilesOpC.Progress;
|
|
||||||
if (_clearUnusedBundleFilesOpC.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_clearUnusedBundleFilesOpC.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _clearUnusedBundleFilesOpC.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -52,16 +52,9 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
ClearCacheBundleFilesOperation IPlayMode.ClearCacheBundleFilesAsync(string clearMode, object clearParam)
|
||||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
|
||||||
{
|
{
|
||||||
var operation = new ClearAllBundleFilesImplOperation(this, EditorFileSystem, null, null);
|
var operation = new ClearCacheBundleFilesImplOperation(this, EditorFileSystem, null, null, clearMode, clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
|
||||||
{
|
|
||||||
var operation = new ClearUnusedBundleFilesImplOperation(this, EditorFileSystem, null, null);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,16 +56,9 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
ClearCacheBundleFilesOperation IPlayMode.ClearCacheBundleFilesAsync(string clearMode, object clearParam)
|
||||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
|
||||||
{
|
{
|
||||||
var operation = new ClearAllBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null);
|
var operation = new ClearCacheBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null, clearMode, clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
|
||||||
{
|
|
||||||
var operation = new ClearUnusedBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,16 +52,9 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
ClearCacheBundleFilesOperation IPlayMode.ClearCacheBundleFilesAsync(string clearMode, object clearParam)
|
||||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
|
||||||
{
|
{
|
||||||
var operation = new ClearAllBundleFilesImplOperation(this, BuildinFileSystem, null, null);
|
var operation = new ClearCacheBundleFilesImplOperation(this, BuildinFileSystem, null, null, clearMode, clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
|
||||||
{
|
|
||||||
var operation = new ClearUnusedBundleFilesImplOperation(this, BuildinFileSystem, null, null);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,16 +74,9 @@ namespace YooAsset
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
ClearCacheBundleFilesOperation IPlayMode.ClearCacheBundleFilesAsync(string clearMode, object clearParam)
|
||||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
|
||||||
{
|
{
|
||||||
var operation = new ClearAllBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null);
|
var operation = new ClearCacheBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null, clearMode, clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
|
||||||
{
|
|
||||||
var operation = new ClearUnusedBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,21 +236,25 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理文件系统所有的资源文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
/// <param name="clearMode">清理方式</param>
|
||||||
|
/// <param name="clearParam">执行参数</param>
|
||||||
|
public ClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return _playModeImpl.ClearAllBundleFilesAsync();
|
return _playModeImpl.ClearCacheBundleFilesAsync(clearMode.ToString(), clearParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理文件系统未使用的资源文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync()
|
/// <param name="clearMode">清理方式</param>
|
||||||
|
/// <param name="clearParam">执行参数</param>
|
||||||
|
public ClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(string clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return _playModeImpl.ClearUnusedBundleFilesAsync();
|
return _playModeImpl.ClearCacheBundleFilesAsync(clearMode, clearParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue