Add clear unused cache files method.
增加清空缓存文件的方法。
This commit is contained in:
@@ -53,7 +53,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
|
||||
if (_steps == ESteps.Update)
|
||||
{
|
||||
_appManifestLoader.Update();
|
||||
@@ -61,7 +61,7 @@ namespace YooAsset
|
||||
return;
|
||||
|
||||
if (_appManifestLoader.Result == null)
|
||||
{
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _appManifestLoader.Error;
|
||||
@@ -110,20 +110,20 @@ namespace YooAsset
|
||||
if (_steps == ESteps.InitCache)
|
||||
{
|
||||
// 每次启动时比对APP版本号是否一致
|
||||
PatchCache cache = PatchCache.LoadCache();
|
||||
if (cache.CacheAppVersion != Application.version)
|
||||
CacheData cacheData = CacheData.LoadCache();
|
||||
if (cacheData.CacheAppVersion != Application.version)
|
||||
{
|
||||
YooLogger.Warning($"Cache is dirty ! Cache app version is {cache.CacheAppVersion}, Current app version is {Application.version}");
|
||||
YooLogger.Warning($"Cache is dirty ! Cache application version is {cacheData.CacheAppVersion}, Current application version is {Application.version}");
|
||||
|
||||
// 注意:在覆盖安装的时候,会保留APP沙盒目录,可以选择清空缓存目录
|
||||
if (_impl.ClearCacheWhenDirty)
|
||||
{
|
||||
YooLogger.Warning("Clear cache files.");
|
||||
SandboxHelper.DeleteSandboxCacheFolder();
|
||||
SandboxHelper.DeleteCacheFolder();
|
||||
}
|
||||
|
||||
// 更新缓存文件
|
||||
PatchCache.UpdateCache();
|
||||
CacheData.UpdateCache();
|
||||
}
|
||||
_steps = ESteps.Update;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ namespace YooAsset
|
||||
|
||||
if (_downloader2.HasError())
|
||||
{
|
||||
Error = _downloader2.GetError();
|
||||
Error = _downloader2.GetError();
|
||||
_steps = ESteps.Failed;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 查看文件是否存在
|
||||
string filePath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
||||
if (File.Exists(filePath) == false)
|
||||
continue;
|
||||
|
||||
@@ -321,7 +321,7 @@ namespace YooAsset
|
||||
}
|
||||
private bool RunThread(PatchBundle patchBundle)
|
||||
{
|
||||
string filePath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
||||
ThreadInfo info = new ThreadInfo(filePath, patchBundle);
|
||||
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), info);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace YooAsset
|
||||
|
||||
// 注意:下载系统只会验证当前游戏版本的资源文件,对于其它游戏版本的差异文件不会在初始化的时候去做校验。
|
||||
// 注意:通过比对文件大小做实时的文件校验方式!
|
||||
string filePath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
long fileSize = FileUtility.GetFileSize(filePath);
|
||||
|
||||
Reference in New Issue
Block a user