From 3d1a28a50e12ae32f28e6adf9b3e66e1345405c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Tue, 11 Feb 2025 15:09:23 +0800 Subject: [PATCH] update file system --- .../DefaultBuildinFileSystem.cs | 6 +-- .../DefaultCacheFileSystem.cs | 40 +++++++++---------- .../DefaultWebServerFileSystem.cs | 6 +-- .../FileSystem/Interface/IFileSystem.cs | 6 +-- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs index 25ec5da3..86c81f98 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/DefaultBuildinFileSystem.cs @@ -21,7 +21,7 @@ namespace YooAsset } protected readonly Dictionary _wrappers = new Dictionary(10000); - protected readonly Dictionary _buildinFilePaths = new Dictionary(10000); + protected readonly Dictionary _buildinFilePathMapping = new Dictionary(10000); protected IFileSystem _unpackFileSystem; protected string _packageRoot; @@ -309,10 +309,10 @@ namespace YooAsset } public string GetBuildinFileLoadPath(PackageBundle bundle) { - if (_buildinFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) + if (_buildinFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) { filePath = PathUtility.Combine(_packageRoot, bundle.FileName); - _buildinFilePaths.Add(bundle.BundleGUID, filePath); + _buildinFilePathMapping.Add(bundle.BundleGUID, filePath); } return filePath; } diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs index 95f8d4d2..17939118 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs @@ -11,10 +11,10 @@ namespace YooAsset /// internal class DefaultCacheFileSystem : IFileSystem { - protected readonly Dictionary _wrappers = new Dictionary(10000); - protected readonly Dictionary _bundleDataFilePaths = new Dictionary(10000); - protected readonly Dictionary _bundleInfoFilePaths = new Dictionary(10000); - protected readonly Dictionary _tempFilePaths = new Dictionary(10000); + protected readonly Dictionary _records = new Dictionary(10000); + protected readonly Dictionary _bundleDataFilePathMapping = new Dictionary(10000); + protected readonly Dictionary _bundleInfoFilePathMapping = new Dictionary(10000); + protected readonly Dictionary _tempFilePathMapping = new Dictionary(10000); protected DefaultCacheDownloadCenter _downloadCenter; protected string _packageRoot; @@ -45,7 +45,7 @@ namespace YooAsset { get { - return _wrappers.Count; + return _records.Count; } } @@ -245,7 +245,7 @@ namespace YooAsset } public virtual bool Exists(PackageBundle bundle) { - return _wrappers.ContainsKey(bundle.BundleGUID); + return _records.ContainsKey(bundle.BundleGUID); } public virtual bool NeedDownload(PackageBundle bundle) { @@ -330,60 +330,60 @@ namespace YooAsset #region 缓存相关 public List GetAllCachedBundleGUIDs() { - return _wrappers.Keys.ToList(); + return _records.Keys.ToList(); } public string GetTempFilePath(PackageBundle bundle) { - if (_tempFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) + if (_tempFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) { filePath = PathUtility.Combine(_tempFilesRoot, bundle.BundleGUID); - _tempFilePaths.Add(bundle.BundleGUID, filePath); + _tempFilePathMapping.Add(bundle.BundleGUID, filePath); } return filePath; } public string GetBundleDataFilePath(PackageBundle bundle) { - if (_bundleDataFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) + if (_bundleDataFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) { string folderName = bundle.FileHash.Substring(0, 2); filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleDataFileName); if (AppendFileExtension) filePath += bundle.FileExtension; - _bundleDataFilePaths.Add(bundle.BundleGUID, filePath); + _bundleDataFilePathMapping.Add(bundle.BundleGUID, filePath); } return filePath; } public string GetBundleInfoFilePath(PackageBundle bundle) { - if (_bundleInfoFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) + if (_bundleInfoFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) { string folderName = bundle.FileHash.Substring(0, 2); filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleInfoFileName); - _bundleInfoFilePaths.Add(bundle.BundleGUID, filePath); + _bundleInfoFilePathMapping.Add(bundle.BundleGUID, filePath); } return filePath; } public bool IsRecordBundleFile(string bundleGUID) { - return _wrappers.ContainsKey(bundleGUID); + return _records.ContainsKey(bundleGUID); } public bool RecordBundleFile(string bundleGUID, RecordFileElement element) { - if (_wrappers.ContainsKey(bundleGUID)) + if (_records.ContainsKey(bundleGUID)) { YooLogger.Error($"{nameof(DefaultCacheFileSystem)} has element : {bundleGUID}"); return false; } - _wrappers.Add(bundleGUID, element); + _records.Add(bundleGUID, element); return true; } public EFileVerifyResult VerifyCacheFile(PackageBundle bundle) { - if (_wrappers.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false) + if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false) return EFileVerifyResult.CacheNotFound; EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High); @@ -391,7 +391,7 @@ namespace YooAsset } public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath) { - if (_wrappers.ContainsKey(bundle.BundleGUID)) + if (_records.ContainsKey(bundle.BundleGUID)) { throw new Exception("Should never get here !"); } @@ -426,7 +426,7 @@ namespace YooAsset } public bool DeleteCacheBundleFile(string bundleGUID) { - if (_wrappers.TryGetValue(bundleGUID, out RecordFileElement wrapper)) + if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper)) { try { @@ -434,7 +434,7 @@ namespace YooAsset FileInfo fileInfo = new FileInfo(dataFilePath); if (fileInfo.Exists) fileInfo.Directory.Delete(true); - _wrappers.Remove(bundleGUID); + _records.Remove(bundleGUID); return true; } catch (Exception e) diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/DefaultWebServerFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/DefaultWebServerFileSystem.cs index 08fd015e..fffb0c1f 100644 --- a/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/DefaultWebServerFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/DefaultWebServerFileSystem/DefaultWebServerFileSystem.cs @@ -21,7 +21,7 @@ namespace YooAsset } protected readonly Dictionary _wrappers = new Dictionary(10000); - protected readonly Dictionary _webFilePaths = new Dictionary(10000); + protected readonly Dictionary _webFilePathMapping = new Dictionary(10000); protected string _webPackageRoot = string.Empty; /// @@ -173,10 +173,10 @@ namespace YooAsset } public string GetWebFileLoadPath(PackageBundle bundle) { - if (_webFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false) + if (_webFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false) { filePath = PathUtility.Combine(_webPackageRoot, bundle.FileName); - _webFilePaths.Add(bundle.BundleGUID, filePath); + _webFilePathMapping.Add(bundle.BundleGUID, filePath); } return filePath; } diff --git a/Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs index fa5ec1cd..8a46fc05 100644 --- a/Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs +++ b/Assets/YooAsset/Runtime/FileSystem/Interface/IFileSystem.cs @@ -20,7 +20,7 @@ namespace YooAsset /// - /// 初始化缓存系统 + /// 初始化文件系统 /// FSInitializeFileSystemOperation InitializeFileSystemAsync(); @@ -30,7 +30,7 @@ namespace YooAsset FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout); /// - /// 查询最新的版本 + /// 查询包裹版本 /// FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout); @@ -40,7 +40,7 @@ namespace YooAsset FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam); /// - /// 下载远端文件 + /// 下载Bundle文件 /// FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param);