From 97fe3b06814e33d45c0c4a495d79103073a300ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Tue, 1 Jul 2025 16:40:01 +0800 Subject: [PATCH] update file system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正2.3.11版本同步加载本地加密文件失败的问题。 --- .../DefaultBuildinFileSystem.cs | 2 +- .../internal/DownloadCenterOperation.cs | 38 ++++++++++--------- .../internal/DownloadNormalFileOperation.cs | 5 ++- .../internal/DownloadResumeFileOperation.cs | 5 ++- .../Operation/FSDownloadFileOperation.cs | 2 +- .../Runtime/ResourcePackage/BundleInfo.cs | 2 +- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs index 946b9ab9..3f833112 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs @@ -126,7 +126,7 @@ namespace YooAsset public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) { // 注意:业务层的解压下载器会依赖内置文件系统的下载方法 - options.LocalFilePath = GetBuildinFileLoadPath(bundle); + options.ImportFilePath = GetBuildinFileLoadPath(bundle); return _unpackFileSystem.DownloadFileAsync(bundle, options); } public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle) diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadCenterOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadCenterOperation.cs index 9523ed52..67eda71c 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadCenterOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadCenterOperation.cs @@ -82,15 +82,31 @@ namespace YooAsset return oldDownloader; } - // 创建新的下载器 - DefaultDownloadFileOperation newDownloader; - if (string.IsNullOrEmpty(options.LocalFilePath)) + // 获取下载地址 + if (string.IsNullOrEmpty(options.ImportFilePath)) { - // 远端下载地址 + // 注意:如果是解压文件系统类,这里会返回本地内置文件的下载路径 options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(bundle.FileName); options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(bundle.FileName); + } + else + { + // 注意:把本地导入文件路径转换为下载器请求地址 + options.MainURL = DownloadSystemHelper.ConvertToWWWPath(options.ImportFilePath); + options.FallbackURL = options.MainURL; + } - // 创建新的下载器 + // 创建新的下载器 + DefaultDownloadFileOperation newDownloader; + bool isRequestLocalFile = DownloadSystemHelper.IsRequestLocalFile(options.MainURL); + if (isRequestLocalFile) + { + newDownloader = new DownloadLocalFileOperation(_fileSystem, bundle, options); + AddChildOperation(newDownloader); + _downloaders.Add(bundle.BundleGUID, newDownloader); + } + else + { if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize) { newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, options); @@ -104,18 +120,6 @@ namespace YooAsset _downloaders.Add(bundle.BundleGUID, newDownloader); } } - else - { - // 注意:把本地文件路径指定为可下载地址 - options.MainURL = DownloadSystemHelper.ConvertToWWWPath(options.LocalFilePath); - options.FallbackURL = options.MainURL; - - // 创建新的下载器 - newDownloader = new DownloadLocalFileOperation(_fileSystem, bundle, options); - AddChildOperation(newDownloader); - _downloaders.Add(bundle.BundleGUID, newDownloader); - } - return newDownloader; } diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadNormalFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadNormalFileOperation.cs index 8204017c..4ddf5f74 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadNormalFileOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadNormalFileOperation.cs @@ -159,9 +159,12 @@ namespace YooAsset { if (ExecuteWhileDone()) { - //TODO 同步加载失败 + //TODO 尝试同步加载远端的资源文件失败 if (Status == EOperationStatus.Failed) + { YooLogger.Error($"Try load bundle {Bundle.BundleName} from remote !"); + YooLogger.Error($"The load remote bundle url : {_requestURL}"); + } _steps = ESteps.Done; break; diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadResumeFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadResumeFileOperation.cs index c6ef2ba0..c18fe924 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadResumeFileOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/DownloadResumeFileOperation.cs @@ -177,9 +177,12 @@ namespace YooAsset { if (ExecuteWhileDone()) { - //TODO 同步加载失败 + //TODO 尝试同步加载远端的资源文件失败 if (Status == EOperationStatus.Failed) + { YooLogger.Error($"Try load bundle {Bundle.BundleName} from remote !"); + YooLogger.Error($"The load remote bundle url : {_requestURL}"); + } _steps = ESteps.Done; break; diff --git a/Assets/YooAsset/Runtime/FileSystem/Operation/FSDownloadFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Operation/FSDownloadFileOperation.cs index 1aa6319f..9703683c 100644 --- a/Assets/YooAsset/Runtime/FileSystem/Operation/FSDownloadFileOperation.cs +++ b/Assets/YooAsset/Runtime/FileSystem/Operation/FSDownloadFileOperation.cs @@ -26,7 +26,7 @@ namespace YooAsset /// /// 拷贝的本地文件路径 /// - public string LocalFilePath { set; get; } + public string ImportFilePath { set; get; } public DownloadFileOptions(int failedTryAgain, int timeout) { diff --git a/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs b/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs index ec9cc439..09a6db29 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs @@ -39,7 +39,7 @@ namespace YooAsset public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout) { DownloadFileOptions options = new DownloadFileOptions(failedTryAgain, timeout); - options.LocalFilePath = _importFilePath; + options.ImportFilePath = _importFilePath; return _fileSystem.DownloadFileAsync(Bundle, options); }