示例#1
0
        /// <summary>
        /// 获取下载列表
        /// </summary>
        private List <BundleInfo> GetDownloadList()
        {
            List <PatchBundle> downloadList = new List <PatchBundle>(1000);

            foreach (var patchBundle in _remotePatchManifest.BundleList)
            {
                // 忽略缓存文件
                if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
                {
                    continue;
                }

                // 忽略APP资源
                // 注意:如果是APP资源并且哈希值相同,则不需要下载
                if (_impl.AppPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
                {
                    if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
                    {
                        continue;
                    }
                }

                // 注意:通过比对文件大小做快速的文件校验!
                // 注意:在初始化的时候会去做最终校验!
                string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
                if (File.Exists(filePath))
                {
                    long fileSize = FileUtility.GetFileSize(filePath);
                    if (fileSize == patchBundle.SizeBytes)
                    {
                        continue;
                    }
                }

                downloadList.Add(patchBundle);
            }

            return(_impl.ConvertToDownloadList(downloadList));
        }
示例#2
0
 /// <summary>
 /// 查询是否为验证文件
 /// 注意:被收录的文件完整性是绝对有效的
 /// </summary>
 public static bool ContainsVerifyFile(string hash)
 {
     if (_cachedHashList.ContainsKey(hash))
     {
         string filePath = SandboxHelper.MakeCacheFilePath(hash);
         if (File.Exists(filePath))
         {
             return(true);
         }
         else
         {
             string bundleName = _cachedHashList[hash];
             _cachedHashList.Remove(hash);
             YooLogger.Error($"Cache file is missing : {bundleName} Hash : {hash}");
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
示例#3
0
        private void InitVerifyingCache()
        {
            // 遍历所有文件然后验证并缓存合法文件
            foreach (var patchBundle in _impl.LocalPatchManifest.BundleList)
            {
                // 忽略缓存文件
                if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
                {
                    continue;
                }

                // 忽略APP资源
                // 注意:如果是APP资源并且哈希值相同,则不需要下载
                if (_impl.AppPatchManifest.Bundles.TryGetValue(patchBundle.BundleName, out PatchBundle appPatchBundle))
                {
                    if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
                    {
                        continue;
                    }
                }

                // 查看文件是否存在
                string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
                if (File.Exists(filePath) == false)
                {
                    continue;
                }

                _waitingList.Add(patchBundle);
            }

            // 设置同时验证的最大数
            ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
            YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
            _verifyMaxNum     = Math.Min(workerThreads, ioThreads);
            _verifyTotalCount = _waitingList.Count;
        }
示例#4
0
 /// <summary>
 /// 清空所有的缓存文件
 /// </summary>
 public static void ClearAllCacheFiles()
 {
     SandboxHelper.DeleteCacheFolder();
 }
示例#5
0
 /// <summary>
 /// 清空沙盒目录
 /// </summary>
 public static void ClearSandbox()
 {
     SandboxHelper.DeleteSandbox();
 }
示例#6
0
        public static bool CheckContentIntegrity(PatchBundle patchBundle)
        {
            string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);

            return(CheckContentIntegrity(filePath, patchBundle.SizeBytes, patchBundle.CRC));
        }