2025-03-14 14:32:39 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace YooAsset
|
|
|
|
|
|
{
|
|
|
|
|
|
internal class DCFSLoadAssetBundleOperation : FSLoadBundleOperation
|
|
|
|
|
|
{
|
2024-07-07 00:52:17 +08:00
|
|
|
|
protected enum ESteps
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
None,
|
2024-07-07 00:52:17 +08:00
|
|
|
|
CheckExist,
|
2024-07-04 20:36:26 +08:00
|
|
|
|
DownloadFile,
|
2025-10-30 18:31:06 +08:00
|
|
|
|
AbortDownload,
|
2024-07-04 20:36:26 +08:00
|
|
|
|
LoadAssetBundle,
|
|
|
|
|
|
CheckResult,
|
|
|
|
|
|
Done,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-07 00:52:17 +08:00
|
|
|
|
protected readonly DefaultCacheFileSystem _fileSystem;
|
|
|
|
|
|
protected readonly PackageBundle _bundle;
|
|
|
|
|
|
protected FSDownloadFileOperation _downloadFileOp;
|
|
|
|
|
|
protected AssetBundleCreateRequest _createRequest;
|
2024-12-24 18:23:19 +08:00
|
|
|
|
private AssetBundle _assetBundle;
|
|
|
|
|
|
private Stream _managedStream;
|
2024-07-07 00:52:17 +08:00
|
|
|
|
protected ESteps _steps = ESteps.None;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal DCFSLoadAssetBundleOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle)
|
|
|
|
|
|
{
|
|
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
|
|
_bundle = bundle;
|
|
|
|
|
|
}
|
2025-02-22 16:29:25 +08:00
|
|
|
|
internal override void InternalStart()
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2024-07-07 00:52:17 +08:00
|
|
|
|
_steps = ESteps.CheckExist;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
2025-02-22 16:29:25 +08:00
|
|
|
|
internal override void InternalUpdate()
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-07-07 00:52:17 +08:00
|
|
|
|
if (_steps == ESteps.CheckExist)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_fileSystem.Exists(_bundle))
|
|
|
|
|
|
{
|
|
|
|
|
|
DownloadProgress = 1f;
|
|
|
|
|
|
DownloadedBytes = _bundle.FileSize;
|
|
|
|
|
|
_steps = ESteps.LoadAssetBundle;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-07-22 18:59:47 +08:00
|
|
|
|
if (_fileSystem.DisableOnDemandDownload)
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
|
Error = $"The bundle not cached : {_bundle.BundleName}";
|
|
|
|
|
|
YooLogger.Warning(Error);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.DownloadFile;
|
|
|
|
|
|
}
|
2024-07-07 00:52:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-30 18:31:06 +08:00
|
|
|
|
if (_steps == ESteps.DownloadFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 中断下载
|
|
|
|
|
|
if (AbortDownloadFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloadFileOp != null)
|
|
|
|
|
|
_downloadFileOp.AbortOperation();
|
|
|
|
|
|
_steps = ESteps.AbortDownload;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-04 20:36:26 +08:00
|
|
|
|
if (_steps == ESteps.DownloadFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloadFileOp == null)
|
|
|
|
|
|
{
|
2025-07-17 20:59:15 +08:00
|
|
|
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
2025-04-08 11:48:32 +08:00
|
|
|
|
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
2025-02-26 19:31:06 +08:00
|
|
|
|
_downloadFileOp.StartOperation();
|
|
|
|
|
|
AddChildOperation(_downloadFileOp);
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-10 16:48:08 +08:00
|
|
|
|
if (IsWaitForAsyncComplete)
|
|
|
|
|
|
_downloadFileOp.WaitForAsyncComplete();
|
|
|
|
|
|
|
2025-02-26 19:31:06 +08:00
|
|
|
|
_downloadFileOp.UpdateOperation();
|
2024-07-04 20:36:26 +08:00
|
|
|
|
DownloadProgress = _downloadFileOp.DownloadProgress;
|
|
|
|
|
|
DownloadedBytes = _downloadFileOp.DownloadedBytes;
|
|
|
|
|
|
if (_downloadFileOp.IsDone == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_downloadFileOp.Status == EOperationStatus.Succeed)
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.LoadAssetBundle;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
2024-07-07 00:52:17 +08:00
|
|
|
|
Error = _downloadFileOp.Error;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-30 18:31:06 +08:00
|
|
|
|
if (_steps == ESteps.AbortDownload)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloadFileOp != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsWaitForAsyncComplete)
|
|
|
|
|
|
_downloadFileOp.WaitForAsyncComplete();
|
|
|
|
|
|
|
|
|
|
|
|
_downloadFileOp.UpdateOperation();
|
|
|
|
|
|
if (_downloadFileOp.IsDone == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
|
Error = "Abort download file !";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-04 20:36:26 +08:00
|
|
|
|
if (_steps == ESteps.LoadAssetBundle)
|
|
|
|
|
|
{
|
2024-08-03 18:43:12 +08:00
|
|
|
|
if (_bundle.Encrypted)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_fileSystem.DecryptionServices == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
|
Error = $"The {nameof(IDecryptionServices)} is null !";
|
|
|
|
|
|
YooLogger.Error(Error);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-17 10:51:17 +08:00
|
|
|
|
if (IsWaitForAsyncComplete)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2024-08-03 18:43:12 +08:00
|
|
|
|
if (_bundle.Encrypted)
|
|
|
|
|
|
{
|
2024-12-24 18:23:19 +08:00
|
|
|
|
var decryptResult = _fileSystem.LoadEncryptedAssetBundle(_bundle);
|
|
|
|
|
|
_assetBundle = decryptResult.Result;
|
|
|
|
|
|
_managedStream = decryptResult.ManagedStream;
|
2024-08-03 18:43:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-01-03 15:08:57 +08:00
|
|
|
|
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
2024-12-24 18:23:19 +08:00
|
|
|
|
_assetBundle = AssetBundle.LoadFromFile(filePath);
|
2024-08-03 18:43:12 +08:00
|
|
|
|
}
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-08-03 18:43:12 +08:00
|
|
|
|
if (_bundle.Encrypted)
|
|
|
|
|
|
{
|
2024-12-24 18:23:19 +08:00
|
|
|
|
var decryptResult = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
|
|
|
|
|
|
_createRequest = decryptResult.CreateRequest;
|
|
|
|
|
|
_managedStream = decryptResult.ManagedStream;
|
2024-08-03 18:43:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-01-03 15:08:57 +08:00
|
|
|
|
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
2024-08-03 18:43:12 +08:00
|
|
|
|
_createRequest = AssetBundle.LoadFromFileAsync(filePath);
|
|
|
|
|
|
}
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
2024-07-27 15:25:21 +08:00
|
|
|
|
|
2024-07-04 20:36:26 +08:00
|
|
|
|
_steps = ESteps.CheckResult;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.CheckResult)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_createRequest != null)
|
|
|
|
|
|
{
|
2024-10-17 10:51:17 +08:00
|
|
|
|
if (IsWaitForAsyncComplete)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
// 强制挂起主线程(注意:该操作会很耗时)
|
|
|
|
|
|
YooLogger.Warning("Suspend the main thread to load unity bundle.");
|
2024-12-24 18:23:19 +08:00
|
|
|
|
_assetBundle = _createRequest.assetBundle;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_createRequest.isDone == false)
|
|
|
|
|
|
return;
|
2024-12-24 18:23:19 +08:00
|
|
|
|
_assetBundle = _createRequest.assetBundle;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-24 18:23:19 +08:00
|
|
|
|
if (_assetBundle != null)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
2024-12-24 18:23:19 +08:00
|
|
|
|
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, _managedStream);
|
2024-07-07 00:52:17 +08:00
|
|
|
|
Status = EOperationStatus.Succeed;
|
2024-08-03 18:43:12 +08:00
|
|
|
|
return;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
2024-08-03 18:43:12 +08:00
|
|
|
|
|
|
|
|
|
|
// 注意:当缓存文件的校验等级为Low的时候,并不能保证缓存文件的完整性。
|
|
|
|
|
|
// 说明:在AssetBundle文件加载失败的情况下,我们需要重新验证文件的完整性!
|
|
|
|
|
|
EFileVerifyResult verifyResult = _fileSystem.VerifyCacheFile(_bundle);
|
|
|
|
|
|
if (verifyResult == EFileVerifyResult.Succeed)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2024-08-03 18:43:12 +08:00
|
|
|
|
if (_bundle.Encrypted)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2025-06-17 17:07:02 +08:00
|
|
|
|
var decryptResult = _fileSystem.LoadEncryptedAssetBundleFallback(_bundle);
|
|
|
|
|
|
_assetBundle = decryptResult.Result;
|
|
|
|
|
|
if (_assetBundle != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, _managedStream);
|
|
|
|
|
|
Status = EOperationStatus.Succeed;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
|
Error = $"Failed to load encrypted asset bundle file : {_bundle.BundleName}";
|
|
|
|
|
|
YooLogger.Error(Error);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-08-03 18:43:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 注意:在安卓移动平台,华为和三星真机上有极小概率加载资源包失败。
|
|
|
|
|
|
// 说明:大多数情况在首次安装下载资源到沙盒内,游戏过程中切换到后台再回到游戏内有很大概率触发!
|
2025-01-03 15:08:57 +08:00
|
|
|
|
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
2024-08-03 18:43:12 +08:00
|
|
|
|
byte[] fileData = FileUtility.ReadAllBytes(filePath);
|
|
|
|
|
|
if (fileData != null && fileData.Length > 0)
|
|
|
|
|
|
{
|
2024-12-24 18:23:19 +08:00
|
|
|
|
_assetBundle = AssetBundle.LoadFromMemory(fileData);
|
|
|
|
|
|
if (_assetBundle == null)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2024-08-03 18:43:12 +08:00
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
|
Error = $"Failed to load asset bundle from memory : {_bundle.BundleName}";
|
|
|
|
|
|
YooLogger.Error(Error);
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
2024-12-24 18:23:19 +08:00
|
|
|
|
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, null);
|
2024-08-03 18:43:12 +08:00
|
|
|
|
Status = EOperationStatus.Succeed;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
2024-08-03 18:43:12 +08:00
|
|
|
|
Error = $"Failed to read asset bundle file bytes : {_bundle.BundleName}";
|
2024-07-04 20:36:26 +08:00
|
|
|
|
YooLogger.Error(Error);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-03 18:43:12 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
2025-01-03 15:08:57 +08:00
|
|
|
|
_fileSystem.DeleteCacheBundleFile(_bundle.BundleGUID);
|
2024-08-03 18:43:12 +08:00
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
|
Error = $"Find corrupted asset bundle file and delete : {_bundle.BundleName}";
|
|
|
|
|
|
YooLogger.Error(Error);
|
|
|
|
|
|
}
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-07 16:01:55 +08:00
|
|
|
|
internal override void InternalWaitForAsyncComplete()
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2026-01-12 11:09:27 +08:00
|
|
|
|
RunBatchExecution();
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal class DCFSLoadRawBundleOperation : FSLoadBundleOperation
|
|
|
|
|
|
{
|
2024-07-07 00:52:17 +08:00
|
|
|
|
protected enum ESteps
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
None,
|
2024-07-07 00:52:17 +08:00
|
|
|
|
CheckExist,
|
2024-07-04 20:36:26 +08:00
|
|
|
|
DownloadFile,
|
2025-10-30 18:31:06 +08:00
|
|
|
|
AbortDownload,
|
2024-07-08 17:36:25 +08:00
|
|
|
|
LoadCacheRawBundle,
|
2024-07-04 20:36:26 +08:00
|
|
|
|
Done,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-07 00:52:17 +08:00
|
|
|
|
protected readonly DefaultCacheFileSystem _fileSystem;
|
|
|
|
|
|
protected readonly PackageBundle _bundle;
|
|
|
|
|
|
protected FSDownloadFileOperation _downloadFileOp;
|
|
|
|
|
|
protected ESteps _steps = ESteps.None;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal DCFSLoadRawBundleOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle)
|
|
|
|
|
|
{
|
|
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
|
|
_bundle = bundle;
|
|
|
|
|
|
}
|
2025-02-22 16:29:25 +08:00
|
|
|
|
internal override void InternalStart()
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2024-07-07 00:52:17 +08:00
|
|
|
|
_steps = ESteps.CheckExist;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
2025-02-22 16:29:25 +08:00
|
|
|
|
internal override void InternalUpdate()
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-07-07 00:52:17 +08:00
|
|
|
|
if (_steps == ESteps.CheckExist)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_fileSystem.Exists(_bundle))
|
|
|
|
|
|
{
|
2025-03-14 14:32:39 +08:00
|
|
|
|
// 注意:缓存的原生文件的格式,可能会在业务端根据需求发生变动!
|
|
|
|
|
|
// 注意:这里需要校验文件格式,如果不一致对本地文件进行修正!
|
|
|
|
|
|
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
|
|
|
|
|
if (File.Exists(filePath) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var recordFileElement = _fileSystem.GetRecordFileElement(_bundle);
|
|
|
|
|
|
File.Move(recordFileElement.DataFilePath, filePath);
|
|
|
|
|
|
_steps = ESteps.LoadCacheRawBundle;
|
|
|
|
|
|
}
|
2025-12-05 15:45:04 +08:00
|
|
|
|
catch (Exception ex)
|
2025-03-14 14:32:39 +08:00
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
2025-12-05 15:45:04 +08:00
|
|
|
|
Error = $"Faild rename raw data file : {ex.Message}";
|
2025-03-14 14:32:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DownloadProgress = 1f;
|
|
|
|
|
|
DownloadedBytes = _bundle.FileSize;
|
|
|
|
|
|
_steps = ESteps.LoadCacheRawBundle;
|
|
|
|
|
|
}
|
2024-07-07 00:52:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.DownloadFile;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-30 18:31:06 +08:00
|
|
|
|
if (_steps == ESteps.DownloadFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 中断下载
|
|
|
|
|
|
if (AbortDownloadFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloadFileOp != null)
|
|
|
|
|
|
_downloadFileOp.AbortOperation();
|
|
|
|
|
|
_steps = ESteps.AbortDownload;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-04 20:36:26 +08:00
|
|
|
|
if (_steps == ESteps.DownloadFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloadFileOp == null)
|
|
|
|
|
|
{
|
2025-07-17 20:59:15 +08:00
|
|
|
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
2025-04-08 11:48:32 +08:00
|
|
|
|
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
2025-02-26 19:31:06 +08:00
|
|
|
|
_downloadFileOp.StartOperation();
|
|
|
|
|
|
AddChildOperation(_downloadFileOp);
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-10 16:48:08 +08:00
|
|
|
|
if (IsWaitForAsyncComplete)
|
|
|
|
|
|
_downloadFileOp.WaitForAsyncComplete();
|
|
|
|
|
|
|
2025-02-26 19:31:06 +08:00
|
|
|
|
_downloadFileOp.UpdateOperation();
|
2024-07-04 20:36:26 +08:00
|
|
|
|
DownloadProgress = _downloadFileOp.DownloadProgress;
|
|
|
|
|
|
DownloadedBytes = _downloadFileOp.DownloadedBytes;
|
|
|
|
|
|
if (_downloadFileOp.IsDone == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_downloadFileOp.Status == EOperationStatus.Succeed)
|
|
|
|
|
|
{
|
2024-07-08 17:36:25 +08:00
|
|
|
|
_steps = ESteps.LoadCacheRawBundle;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
2024-07-07 00:52:17 +08:00
|
|
|
|
Error = _downloadFileOp.Error;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-30 18:31:06 +08:00
|
|
|
|
if (_steps == ESteps.AbortDownload)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloadFileOp != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsWaitForAsyncComplete)
|
|
|
|
|
|
_downloadFileOp.WaitForAsyncComplete();
|
|
|
|
|
|
|
|
|
|
|
|
_downloadFileOp.UpdateOperation();
|
|
|
|
|
|
if (_downloadFileOp.IsDone == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
|
Error = "Abort download file !";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-08 17:36:25 +08:00
|
|
|
|
if (_steps == ESteps.LoadCacheRawBundle)
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2025-01-03 15:08:57 +08:00
|
|
|
|
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
2024-07-08 17:36:25 +08:00
|
|
|
|
if (File.Exists(filePath))
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2024-07-08 17:36:25 +08:00
|
|
|
|
_steps = ESteps.Done;
|
2024-12-24 18:23:19 +08:00
|
|
|
|
Result = new RawBundleResult(_fileSystem, _bundle);
|
2024-07-08 17:36:25 +08:00
|
|
|
|
Status = EOperationStatus.Succeed;
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
2024-07-08 17:36:25 +08:00
|
|
|
|
Error = $"Can not found cache raw bundle file : {filePath}";
|
2024-08-03 18:43:12 +08:00
|
|
|
|
YooLogger.Error(Error);
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-07 16:01:55 +08:00
|
|
|
|
internal override void InternalWaitForAsyncComplete()
|
2024-07-04 20:36:26 +08:00
|
|
|
|
{
|
2026-01-12 11:09:27 +08:00
|
|
|
|
RunBatchExecution();
|
2024-07-04 20:36:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|