Update PatchSystem
增加清理缓存资源的异步操作类
This commit is contained in:
@@ -88,16 +88,18 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空未被使用的缓存文件
|
||||
/// 获取未被使用的缓存文件路径集合
|
||||
/// </summary>
|
||||
public void ClearUnusedCacheFiles()
|
||||
public List<string> ClearUnusedCacheFilePaths()
|
||||
{
|
||||
string cacheFolderPath = SandboxHelper.GetCacheFolderPath();
|
||||
if (Directory.Exists(cacheFolderPath) == false)
|
||||
return;
|
||||
return new List<string>();
|
||||
|
||||
DirectoryInfo directoryInfo = new DirectoryInfo(cacheFolderPath);
|
||||
foreach (FileInfo fileInfo in directoryInfo.GetFiles())
|
||||
FileInfo[] fileInfos = directoryInfo.GetFiles();
|
||||
List<string> result = new List<string>(fileInfos.Length);
|
||||
foreach (FileInfo fileInfo in fileInfos)
|
||||
{
|
||||
bool used = false;
|
||||
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
||||
@@ -109,11 +111,9 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
if (used == false)
|
||||
{
|
||||
YooLogger.Log($"Delete unused cache file : {fileInfo.Name}");
|
||||
File.Delete(fileInfo.FullName);
|
||||
}
|
||||
result.Add(fileInfo.FullName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user