Esempio n. 1
0
        /// <summary>
        /// 开始下载资源文件
        /// 注意:只有第一次请求的参数才是有效的
        /// </summary>
        public static DownloaderBase BeginDownload(BundleInfo bundleInfo, int failedTryAgain, int timeout = 60)
        {
            // 查询存在的下载器
            if (_downloaderDic.TryGetValue(bundleInfo.Hash, out var downloader))
            {
                return(downloader);
            }

            // 如果资源已经缓存
            if (ContainsVerifyFile(bundleInfo.Hash))
            {
                var tempDownloader = new TempDownloader(bundleInfo);
                return(tempDownloader);
            }

            // 创建新的下载器
            {
                YooLogger.Log($"Beginning to download file : {bundleInfo.BundleName} URL : {bundleInfo.RemoteMainURL}");
                FileUtility.CreateFileDirectory(bundleInfo.GetCacheLoadPath());
                DownloaderBase newDownloader;
                if (bundleInfo.SizeBytes >= _breakpointResumeFileSize)
                {
                    newDownloader = new HttpDownloader(bundleInfo);
                }
                else
                {
                    newDownloader = new FileDownloader(bundleInfo);
                }
                newDownloader.SendRequest(failedTryAgain, timeout);
                _downloaderDic.Add(bundleInfo.Hash, newDownloader);
                return(newDownloader);
            }
        }
Esempio n. 2
0
 // 验证文件完整性
 public static bool CheckContentIntegrity(BundleInfo bundleInfo)
 {
     return(CheckContentIntegrity(bundleInfo.GetCacheLoadPath(), bundleInfo.SizeBytes, bundleInfo.CRC));
 }