From a6ee571d65cf62dcaef613c182ddcffed03d6849 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= <hevinci@hotmail.com>
Date: Thu, 13 Feb 2025 18:56:24 +0800
Subject: [PATCH] update file system

---
 .../Operation/DWRFSLoadBundleOperation.cs     |  4 ++--
 .../Operation/DWSFSLoadBundleOperation.cs     |  2 +-
 .../DownloadWebEncryptAssetBundleOperation.cs | 19 ++++++++++++++++---
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/Operation/DWRFSLoadBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/Operation/DWRFSLoadBundleOperation.cs
index b3edf4a9..7cd11d27 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/Operation/DWRFSLoadBundleOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultWebRemoteFileSystem/Operation/DWRFSLoadBundleOperation.cs
@@ -40,7 +40,7 @@ namespace YooAsset
 
                     if (_bundle.Encrypted)
                     {
-                        _downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(_fileSystem.DecryptionServices, _bundle, downloadParam);
+                        _downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
                         OperationSystem.StartOperation(_fileSystem.PackageName, _downloadAssetBundleOp);
                     }
                     else
@@ -59,7 +59,7 @@ namespace YooAsset
                 if (_downloadAssetBundleOp.Status == EOperationStatus.Succeed)
                 {
                     var assetBundle = _downloadAssetBundleOp.Result;
-                    if(assetBundle == null)
+                    if (assetBundle == null)
                     {
                         _steps = ESteps.Done;
                         Status = EOperationStatus.Failed;
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/Operation/DWSFSLoadBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/Operation/DWSFSLoadBundleOperation.cs
index b57fc776..e3129a65 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/Operation/DWSFSLoadBundleOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/Operation/DWSFSLoadBundleOperation.cs
@@ -41,7 +41,7 @@ namespace YooAsset
 
                     if (_bundle.Encrypted)
                     {
-                        _downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(_fileSystem.DecryptionServices, _bundle, downloadParam);
+                        _downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
                         OperationSystem.StartOperation(_fileSystem.PackageName, _downloadAssetBundleOp);
                     }
                     else
diff --git a/Assets/YooAsset/Runtime/FileSystem/Operation/Internal/DownloadWebEncryptAssetBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Operation/Internal/DownloadWebEncryptAssetBundleOperation.cs
index 928f429c..9636dd88 100644
--- a/Assets/YooAsset/Runtime/FileSystem/Operation/Internal/DownloadWebEncryptAssetBundleOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/Operation/Internal/DownloadWebEncryptAssetBundleOperation.cs
@@ -5,12 +5,14 @@ namespace YooAsset
 {
     internal class DownloadWebEncryptAssetBundleOperation : DownloadAssetBundleOperation
     {
+        private readonly bool _checkTimeout;
         private readonly IWebDecryptionServices _decryptionServices;
         private DownloadHandlerBuffer _downloadhandler;
         private ESteps _steps = ESteps.None;
 
-        internal DownloadWebEncryptAssetBundleOperation(IWebDecryptionServices decryptionServices, PackageBundle bundle, DownloadParam param) : base(bundle, param)
+        internal DownloadWebEncryptAssetBundleOperation(bool checkTimeout, IWebDecryptionServices decryptionServices, PackageBundle bundle, DownloadParam param) : base(bundle, param)
         {
+            _checkTimeout = checkTimeout;
             _decryptionServices = decryptionServices;
         }
         internal override void InternalOnStart()
@@ -45,7 +47,8 @@ namespace YooAsset
                 Progress = DownloadProgress;
                 if (_webRequest.isDone == false)
                 {
-                    CheckRequestTimeout();
+                    if (_checkTimeout)
+                        CheckRequestTimeout();
                     return;
                 }
 
@@ -61,7 +64,17 @@ namespace YooAsset
                         return;
                     }
 
-                    AssetBundle assetBundle = LoadEncryptedAssetBundle(_downloadhandler.data);
+                    var fileData = _downloadhandler.data;
+                    if (fileData == null || fileData.Length == 0)
+                    {
+                        _steps = ESteps.Done;
+                        Status = EOperationStatus.Failed;
+                        Error = $"The download handler data is null or empty !";
+                        YooLogger.Error(Error);
+                        return;
+                    }
+
+                    AssetBundle assetBundle = LoadEncryptedAssetBundle(fileData);
                     if (assetBundle == null)
                     {
                         _steps = ESteps.Done;