示例#1
0
        /// <summary>
        /// 下载记录主资源或补丁列表的文件列表
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private IEnumerator GetFilePatchCache(FilePatchInfo info)
        {
            if (info.isNeedDownFile)
            {
                ActionState(State.DownPathList);
                yield return(Access.FromRemote(info.fileUrl, res =>
                {
                    if (res == null)
                    {
                        return;
                    }
                    var hash = res.MD5();
                    if (info.IsEncrypt())
                    {
                        if (hash != info.encrypt_hash)
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (hash != info.content_hash)
                        {
                            return;
                        }
                    }
                    File.WriteAllBytes(info.fileLocal, res);
                }));
            }

            ActionState(State.GetPatchList);
            MinVersion = Math.Min(MinVersion, info.firstVersion);
            MaxVersion = Math.Max(MaxVersion, info.lastVersion);

            if (File.Exists(info.fileLocal))
            {
                byte[] bytes = File.ReadAllBytes(info.fileLocal);
                if (bytes.Length == 0)
                {
                    yield break;
                }

                ActionState(State.ApplyPatchList);
                string content = info.IsEncrypt() ? bytes.AES_Dencrypt() : Encoding.UTF8.GetString(bytes);
                patchCache[info.fileUrl] = Library.Helper.JsonHelper.ToObject <FileVersion.FileDetailInfo[]>(
                    content.Trim())
                                           .Select(p => new FileDetailInfo(info, p))
                                           .ToDictionary(p => p.path);
            }
            else
            {
                Debug.LogError("file is not exist! " + info.fileLocal);
            }
        }
示例#2
0
        public FileDetailInfo(FilePatchInfo info, FileVersion.FileDetailInfo fileInfo)
        {
            this.dataType = DataType.PersistentDataPath;
            patchInfo     = info;

            path         = fileInfo.path;
            version      = fileInfo.version;
            is_delete    = fileInfo.is_delete;
            content_size = fileInfo.content_size;
            content_hash = fileInfo.content_hash;

            if (patchInfo.IsEncrypt())
            {
                is_ready = false;
            }
            if (content_hash == localhash)
            {
                is_ready = true;
            }

            name = Path.GetFileName(path);
            url  = string.Format("{0}?v={1}", path, version);
        }