mirror of https://github.com/tuyoogame/YooAsset
fix #512
parent
4599ff098c
commit
600e928ab4
|
@ -333,6 +333,13 @@ namespace YooAsset
|
|||
{
|
||||
return _records.Keys.ToList();
|
||||
}
|
||||
public RecordFileElement GetRecordFileElement(PackageBundle bundle)
|
||||
{
|
||||
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement element))
|
||||
return element;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public string GetTempFilePath(PackageBundle bundle)
|
||||
{
|
||||
|
@ -384,10 +391,10 @@ namespace YooAsset
|
|||
|
||||
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
||||
{
|
||||
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
|
||||
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement element) == false)
|
||||
return EFileVerifyResult.CacheNotFound;
|
||||
|
||||
EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
||||
EFileVerifyResult result = FileVerifyHelper.FileVerify(element.DataFilePath, element.DataFileSize, element.DataFileCRC, EFileVerifyLevel.High);
|
||||
return result;
|
||||
}
|
||||
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
|
||||
|
@ -427,10 +434,10 @@ namespace YooAsset
|
|||
}
|
||||
public bool DeleteCacheBundleFile(string bundleGUID)
|
||||
{
|
||||
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
||||
if (_records.TryGetValue(bundleGUID, out RecordFileElement element))
|
||||
{
|
||||
_records.Remove(bundleGUID);
|
||||
return wrapper.DeleteFolder();
|
||||
return element.DeleteFolder();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
|
@ -260,9 +261,30 @@ namespace YooAsset
|
|||
{
|
||||
if (_fileSystem.Exists(_bundle))
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
_steps = ESteps.LoadCacheRawBundle;
|
||||
// 注意:缓存的原生文件的格式,可能会在业务端根据需求发生变动!
|
||||
// 注意:这里需要校验文件格式,如果不一致对本地文件进行修正!
|
||||
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordFileElement = _fileSystem.GetRecordFileElement(_bundle);
|
||||
File.Move(recordFileElement.DataFilePath, filePath);
|
||||
_steps = ESteps.LoadCacheRawBundle;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Faild rename raw data file : {e.Message}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
_steps = ESteps.LoadCacheRawBundle;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -92,12 +92,7 @@ namespace YooAsset
|
|||
if (_fileSystem.AppendFileExtension)
|
||||
{
|
||||
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
||||
if (string.IsNullOrEmpty(dataFileExtension))
|
||||
{
|
||||
//注意:覆盖安装的情况下,缓存文件可能会没有后缀格式,需要删除重新下载!
|
||||
dataFilePath = string.Empty;
|
||||
}
|
||||
else
|
||||
if (string.IsNullOrEmpty(dataFileExtension) == false)
|
||||
{
|
||||
dataFilePath += dataFileExtension;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue