fix #402
This commit is contained in:
+29
-28
@@ -1,13 +1,10 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理所有文件
|
||||
/// </summary>
|
||||
public abstract class ClearAllBundleFilesOperation : AsyncOperationBase
|
||||
public abstract class ClearCacheBundleFilesOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
internal sealed class ClearAllBundleFilesImplOperation : ClearAllBundleFilesOperation
|
||||
internal sealed class ClearCacheBundleFilesImplOperation : ClearCacheBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -22,17 +19,21 @@ namespace YooAsset
|
||||
private readonly IFileSystem _fileSystemA;
|
||||
private readonly IFileSystem _fileSystemB;
|
||||
private readonly IFileSystem _fileSystemC;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpA;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpB;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpC;
|
||||
private readonly string _clearMode;
|
||||
private readonly object _clearParam;
|
||||
private FSClearCacheBundleFilesOperation _clearCacheBundleFilesOpA;
|
||||
private FSClearCacheBundleFilesOperation _clearCacheBundleFilesOpB;
|
||||
private FSClearCacheBundleFilesOperation _clearCacheBundleFilesOpC;
|
||||
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;
|
||||
_fileSystemA = fileSystemA;
|
||||
_fileSystemB = fileSystemB;
|
||||
_fileSystemC = fileSystemC;
|
||||
_clearMode = clearMode;
|
||||
_clearParam = clearParam;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
@@ -51,14 +52,14 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearAllBundleFilesOpA == null)
|
||||
_clearAllBundleFilesOpA = _fileSystemA.ClearAllBundleFilesAsync();
|
||||
if (_clearCacheBundleFilesOpA == null)
|
||||
_clearCacheBundleFilesOpA = _fileSystemA.ClearCacheBundleFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||
|
||||
Progress = _clearAllBundleFilesOpA.Progress;
|
||||
if (_clearAllBundleFilesOpA.IsDone == false)
|
||||
Progress = _clearCacheBundleFilesOpA.Progress;
|
||||
if (_clearCacheBundleFilesOpA.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearAllBundleFilesOpA.Status == EOperationStatus.Succeed)
|
||||
if (_clearCacheBundleFilesOpA.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemB;
|
||||
}
|
||||
@@ -66,7 +67,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearAllBundleFilesOpA.Error;
|
||||
Error = _clearCacheBundleFilesOpA.Error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,14 +79,14 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearAllBundleFilesOpB == null)
|
||||
_clearAllBundleFilesOpB = _fileSystemB.ClearAllBundleFilesAsync();
|
||||
if (_clearCacheBundleFilesOpB == null)
|
||||
_clearCacheBundleFilesOpB = _fileSystemB.ClearCacheBundleFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||
|
||||
Progress = _clearAllBundleFilesOpB.Progress;
|
||||
if (_clearAllBundleFilesOpB.IsDone == false)
|
||||
Progress = _clearCacheBundleFilesOpB.Progress;
|
||||
if (_clearCacheBundleFilesOpB.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearAllBundleFilesOpB.Status == EOperationStatus.Succeed)
|
||||
if (_clearCacheBundleFilesOpB.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemC;
|
||||
}
|
||||
@@ -93,7 +94,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearAllBundleFilesOpB.Error;
|
||||
Error = _clearCacheBundleFilesOpB.Error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,14 +107,14 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearAllBundleFilesOpC == null)
|
||||
_clearAllBundleFilesOpC = _fileSystemC.ClearAllBundleFilesAsync();
|
||||
if (_clearCacheBundleFilesOpC == null)
|
||||
_clearCacheBundleFilesOpC = _fileSystemC.ClearCacheBundleFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||
|
||||
Progress = _clearAllBundleFilesOpC.Progress;
|
||||
if (_clearAllBundleFilesOpC.IsDone == false)
|
||||
Progress = _clearCacheBundleFilesOpC.Progress;
|
||||
if (_clearCacheBundleFilesOpC.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearAllBundleFilesOpC.Status == EOperationStatus.Succeed)
|
||||
if (_clearCacheBundleFilesOpC.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
@@ -122,7 +123,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearAllBundleFilesOpC.Error;
|
||||
Error = _clearCacheBundleFilesOpC.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f25029d71d0d8c4dad70987bda364bf
|
||||
guid: 37b4e645f7a679f4fa978c55329ee01a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39028a4006030f1469b636b0c8b3805a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user