Esempio n. 1
0
        public static List <BundleInfo> GetUnpackListByAll(PatchManifest appPatchManifest)
        {
            // 注意:离线运行模式也依赖下面逻辑,所以判断沙盒内文件是否存在不能通过缓存系统去验证。
            List <PatchBundle> downloadList = new List <PatchBundle>(1000);

            foreach (var patchBundle in appPatchManifest.BundleList)
            {
                // 如果已经在沙盒内
                string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
                if (System.IO.File.Exists(filePath))
                {
                    continue;
                }

                // 如果不是内置资源
                if (patchBundle.IsBuildin == false)
                {
                    continue;
                }

                downloadList.Add(patchBundle);
            }

            return(ConvertToUnpackList(downloadList));
        }
Esempio n. 2
0
        private bool RunThread(PatchBundle patchBundle)
        {
            string     filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
            ThreadInfo info     = new ThreadInfo(filePath, patchBundle);

            return(ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), info));
        }
Esempio n. 3
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));
        }
Esempio n. 4
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);
     }
 }
Esempio n. 5
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;
        }
Esempio n. 6
0
        public static bool CheckContentIntegrity(PatchBundle patchBundle)
        {
            string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);

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