diff --git a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs index 70f58b6..ec62407 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystem.cs @@ -16,10 +16,15 @@ namespace YooAsset private static readonly List _removeList = new List(100); /// - /// 启用断点续传的文件大小 + /// 启用断点续传功能文件的最小字节数 /// public static int BreakpointResumeFileSize { set; get; } = int.MaxValue; + /// + /// 下载失败后清理文件的HTTP错误码 + /// + public static List ClearFileResponseCodes { set; get; } + /// /// 更新所有下载器 /// diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs index b32a6eb..4c0ae44 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Downloader/FileDownloader.cs @@ -156,13 +156,26 @@ namespace YooAsset // 如果下载失败 if (hasError) { - // 注意:非断点续传下载失败后删除文件 + // 注意:非断点续传下载失败之后删除文件 if (_breakResume == false) { string cacheFilePath = _bundleInfo.Bundle.CachedFilePath; if (File.Exists(cacheFilePath)) File.Delete(cacheFilePath); } + else + { + // 注意:下载断点续传文件发生特殊错误码之后删除文件 + if (DownloadSystem.ClearFileResponseCodes != null) + { + if (DownloadSystem.ClearFileResponseCodes.Contains(_webRequest.responseCode)) + { + string cacheFilePath = _bundleInfo.Bundle.CachedFilePath; + if (File.Exists(cacheFilePath)) + File.Delete(cacheFilePath); + } + } + } // 失败后重新尝试 if (_failedTryAgain > 0) diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 0966995..3f68b89 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -147,7 +147,7 @@ namespace YooAsset #region 系统参数 /// - /// 启用下载系统的断点续传功能的文件大小 + /// 设置下载系统参数,启用断点续传功能文件的最小字节数 /// public static void SetDownloadSystemBreakpointResumeFileSize(int fileBytes) { @@ -155,7 +155,15 @@ namespace YooAsset } /// - /// 设置异步系统的每帧允许运行的最大时间切片(单位:毫秒) + /// 设置下载系统参数,下载失败后清理文件的HTTP错误码 + /// + public static void SetDownloadSystemClearFileResponseCode(List codes) + { + DownloadSystem.ClearFileResponseCodes = codes; + } + + /// + /// 设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒) /// public static void SetOperationSystemMaxTimeSlice(long milliseconds) { @@ -168,7 +176,7 @@ namespace YooAsset } /// - /// 设置缓存系统的已经缓存文件的校验等级 + /// 设置缓存系统参数,已经缓存文件的校验等级 /// public static void SetCacheSystemCachedFileVerifyLevel(EVerifyLevel verifyLevel) {