public float CheckUpdateList(List <UpdateInfo> update_infos) { if (m_main_sqlite != null && !AppConst.IgnoreUpdateState) { #region -检查所有文件的version,md5,移除本地db中远程版本没有的文件 string res_work_path = AppUtil.DataPath;//c:/luaframework/ List <DbFileInfo> delete_infolist = m_main_sqlite.CacheFileList(); int index = 0; while (index < delete_infolist.Count) { DbFileInfo old_dbinfo = delete_infolist[index]; DbFileInfo new_dbInfo; if (this.m_remote_version.TryGetValue(old_dbinfo.file_name, out new_dbInfo)) { bool is_need_new = false; string file_path = new_dbInfo.file_name; if (m_ignore_str.Count != 0) { foreach (string item in m_ignore_str) { file_path = file_path.Replace(item, ""); } } string full_path = res_work_path + file_path; if (new_dbInfo.version != old_dbinfo.version) { is_need_new = true; if (AppConst.OpenDownloadLog) { Debug.Log(string.Format("res version is not new , need updata::{0},{1},{2},", full_path, new_dbInfo.version, old_dbinfo.version)); } } else { if (!Util.CheckMd5(full_path, new_dbInfo.file_md5, false)) { if (this.m_zip_state && Util.AssetBundleExists(full_path)) { is_need_new = false; } else { is_need_new = true; if (AppConst.OpenDownloadLog) { Debug.Log(string.Format("res md5 is not new , need updata::{0},{1},", full_path, new_dbInfo.file_md5)); } } } } if (!is_need_new) { this.m_remote_version.Remove(old_dbinfo.file_name); } delete_infolist.RemoveAt(index); } else { index++; } } DeleteFileInfoList(delete_infolist);//移除本地db中远程版本没有的文件 #endregion #region -处理剩下需要更新的必要资源信息 float update_size = 0f; foreach (KeyValuePair <string, DbFileInfo> item in this.m_remote_version) { DbFileInfo info = item.Value; string local_file_name = info.file_name; if (this.m_ignore_str.Count != 0) { foreach (string str in this.m_ignore_str) { local_file_name = local_file_name.Replace(str, ""); } } string path = res_work_path + local_file_name; UpdateInfo update_info = new UpdateInfo(); int file_version = ResUpdateManager.Instance.GetFileVersion(info.file_name); string file_name = info.file_name; if (this.m_zip_dir.Equals("")) { file_name = file_name.Remove(0, 1); } update_info.http_str = string.Concat(new object[] { this.m_http_path, this.m_zip_dir, file_name, this.m_zip_ext, "?v=", file_version }); update_info.file_path = path; update_info.count = 0; update_info.func = delegate(byte[] buffer) { Pathtool.DeleteToFile(path); byte[] new_data = buffer; if (this.m_zip_state) { new_data = ZlibStream.UncompressBuffer(buffer); } bool result2; if (Pathtool.SaveDataToFile(path, new_data)) { string md5; if (this.m_zip_state) { md5 = Md5Helper.Md5Buffer(buffer); } else { md5 = Md5Helper.Md5Buffer(new_data); } if (!info.file_md5.Equals(md5.Remove(8))) { result2 = false; } else { info.file_md5 = md5; this.m_main_sqlite.ReplaceFileInfoToDb(info); result2 = true; } } else { result2 = false; } return(result2); }; int file_size; if (this.m_zip_state) { file_size = info.data_len / 10 / 1024; } else { file_size = info.data_len / 1024; } update_info.file_size = file_size; update_infos.Add(update_info); update_size += (float)file_size; } #endregion return(update_size); } return(0); }