mirror of https://github.com/tuyoogame/YooAsset
parent
4d2df5b705
commit
4599ff098c
|
@ -429,20 +429,8 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
string dataFilePath = wrapper.DataFilePath;
|
|
||||||
FileInfo fileInfo = new FileInfo(dataFilePath);
|
|
||||||
if (fileInfo.Exists)
|
|
||||||
fileInfo.Directory.Delete(true);
|
|
||||||
_records.Remove(bundleGUID);
|
_records.Remove(bundleGUID);
|
||||||
return true;
|
return wrapper.DeleteFolder();
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class RecordFileElement
|
internal class RecordFileElement
|
||||||
|
@ -15,5 +17,31 @@ namespace YooAsset
|
||||||
DataFileCRC = dataFileCRC;
|
DataFileCRC = dataFileCRC;
|
||||||
DataFileSize = dataFileSize;
|
DataFileSize = dataFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除记录文件
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteFolder()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string directory = Path.GetDirectoryName(InfoFilePath);
|
||||||
|
DirectoryInfo directoryInfo = new DirectoryInfo(directory);
|
||||||
|
if (directoryInfo.Exists)
|
||||||
|
{
|
||||||
|
directoryInfo.Delete(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,9 +7,10 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
CheckArgs,
|
CheckArgs,
|
||||||
GetTagsCacheFiles,
|
GetClearCacheFiles,
|
||||||
ClearTagsCacheFiles,
|
ClearFilterCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,13 +30,27 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckArgs;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckArgs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckArgs)
|
if (_steps == ESteps.CheckArgs)
|
||||||
{
|
{
|
||||||
if (_clearParam == null)
|
if (_clearParam == null)
|
||||||
|
@ -67,17 +82,17 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.GetTagsCacheFiles;
|
_steps = ESteps.GetClearCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.GetTagsCacheFiles)
|
if (_steps == ESteps.GetClearCacheFiles)
|
||||||
{
|
{
|
||||||
_clearBundleGUIDs = GetTagsBundleGUIDs();
|
_clearBundleGUIDs = GetBundleGUIDsByTag();
|
||||||
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
||||||
_steps = ESteps.ClearTagsCacheFiles;
|
_steps = ESteps.ClearFilterCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.ClearTagsCacheFiles)
|
if (_steps == ESteps.ClearFilterCacheFiles)
|
||||||
{
|
{
|
||||||
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
@ -100,7 +115,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetTagsBundleGUIDs()
|
private List<string> GetBundleGUIDsByTag()
|
||||||
{
|
{
|
||||||
var allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
|
var allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
|
||||||
List<string> result = new List<string>(allBundleGUIDs.Count);
|
List<string> result = new List<string>(allBundleGUIDs.Count);
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
GetUnusedCacheFiles,
|
GetUnusedCacheFiles,
|
||||||
ClearUnusedCacheFiles,
|
ClearUnusedCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
|
@ -27,13 +28,27 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.GetUnusedCacheFiles;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.GetUnusedCacheFiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.GetUnusedCacheFiles)
|
if (_steps == ESteps.GetUnusedCacheFiles)
|
||||||
{
|
{
|
||||||
_unusedBundleGUIDs = GetUnusedBundleGUIDs();
|
_unusedBundleGUIDs = GetUnusedBundleGUIDs();
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
ClearUnusedCacheFiles,
|
ClearUnusedCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
@ -24,13 +25,27 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.ClearUnusedCacheFiles;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.ClearUnusedCacheFiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.ClearUnusedCacheFiles)
|
if (_steps == ESteps.ClearUnusedCacheFiles)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -263,7 +263,7 @@ namespace YooAsset
|
||||||
/// <param name="clearParam">执行参数</param>
|
/// <param name="clearParam">执行参数</param>
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
|
@ -276,7 +276,7 @@ namespace YooAsset
|
||||||
/// <param name="clearParam">执行参数</param>
|
/// <param name="clearParam">执行参数</param>
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
|
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
|
|
Loading…
Reference in New Issue