private IEnumerator GetExceptionList() { downloadSize = 0; exceptionList = new Dictionary <string, List <string> >(); versionFileName = new List <string>(ABVersion.CurVersionInfo.VersionInfoList.Keys); int index = 0; string key = ""; string abFullPath = ""; float count = versionFileName.Count; while (index < versionFileName.Count) { key = versionFileName[index]; List <string> value = ABVersion.CurVersionInfo.VersionInfoList[key]; if (int.Parse(value[1]) > ABVersion.OriginalVersionId.Id3rd) { bool fromNativePath = true; abFullPath = ABVersion.CurVersionInfo.GetABFullPath(key, ref fromNativePath); if (!fromNativePath && ABHelper.BuildMD5ByFile(abFullPath) != value[0]) { exceptionList.Add(key, value); downloadSize += long.Parse(value[2]); } } CheckFileProcess(++index / count); yield return(null); } //判断是否存在异常 if (exceptionList.Count > 0) { DownloadExceptionFile(); } else { FixResult(true); } yield return(null); }
private static void CreatVersionTxt() { // 版号文件 string fileUrl = CreatFileUrlMd5(ABHelper.VersionNumFileName); ABHelper.WriteVersionNumFile(CurVersionABExportPath + fileUrl, ABHelper.VersionNumCombine(TheVersionNum[0], TheVersionNum[1], CurVersionNum.ToString(), TheVersionNum[3])); // ab的依赖文件 fileUrl = CreatFileUrlMd5(ABHelper.ManifestFileName); ABHelper.WriteManifestFile(CurVersionABExportPath + fileUrl, ResFolder, CurVersionManifestList); // 创建版本文件 CurVersionList = ABHelper.ReadVersionFile(PlatformABExportPath + "/" + (CurVersionNum - 1) + "/" + ABHelper.VersionFileName); List <string> filePaths = ABHelper.GetAllFilesPathInDir(CurVersionABExportPath); foreach (string path in filePaths) { if (path.EndsWith(".manifest")) { continue; } string path2 = path.Replace("\\", "/").Replace(CurVersionABExportPath, "").ToLower(); if (path2.Equals(CurVersionNum.ToString()) || path2.Equals(ABHelper.DependFileName) || path2.Equals(ABHelper.Md5FileName)) { continue; } string value = CurVersionFileUrlMd5[path2].ToLower(); if (CurVersionList.ContainsKey(value)) { CurVersionList.Remove(value); } CurVersionList.Add(value, new List <string>() { ABHelper.BuildMD5ByFile(path), CurVersionNum.ToString(), ABHelper.FileSize(path).ToString(), path2 }); } ABHelper.WriteVersionFile(CurVersionABExportPath + ABHelper.VersionFileName, CurVersionList); }
private static void CreatFileDependencies() { List <string> scriptPathList = new List <string>(); List <string> folderBundlePathList = new List <string>(); List <string> fileBundlePathList = new List <string>(); List <string> sceneBundlePathList = new List <string>(); List <string> luaPathList = new List <string>(); foreach (string path in ScriptFolderPath) { string fullPath = AssetFolder + path; scriptPathList.AddRange(ABHelper.GetAllFilesPathInDir(fullPath)); } foreach (string path in BundleFolderPath) { string fullPath = ResFolder + path; folderBundlePathList.AddRange(ABHelper.GetAllFilesPathInDir(fullPath)); } foreach (string path in BundleFilePath) { string fullPath = ResFolder + path; fileBundlePathList.AddRange(ABHelper.GetAllFilesPathInDir(fullPath)); } foreach (string path in BundleScenePath) { string fullPath = AssetFolder + path; sceneBundlePathList.AddRange(ABHelper.GetAllFilesPathInDir(fullPath)); } foreach (string path in BundleLuaPath) { string fullPath = AssetFolder + path; luaPathList.AddRange(ABHelper.GetAllFilesPathInDir(fullPath)); } CurVersionFileType = new Dictionary <string, string>(); CurVersionDependenciesList = new Dictionary <string, List <string> >(); CurVersionManifestList = new Dictionary <string, List <string> >(); CurVersionMd5List = new Dictionary <string, string>(); foreach (string path in scriptPathList) { if (!IsScriptFileRes(path)) { continue; } string filePath = path.Replace("\\", "/"); if (!CurVersionMd5List.ContainsKey(filePath)) { CurVersionMd5List.Add(filePath, ABHelper.BuildMD5ByFile(filePath)); } if (!CurVersionDependenciesList.ContainsKey(filePath)) { CurVersionDependenciesList.Add(filePath, new List <string>()); CurVersionFileType.Add(filePath, "4"); } CurVersionDependenciesList[filePath].Add(filePath); } foreach (string path in folderBundlePathList) { if (!IsNeedFileRes(path)) { continue; } string filePath = path.Replace("\\", "/"); if (!CurVersionMd5List.ContainsKey(filePath)) { CurVersionMd5List.Add(filePath, ABHelper.BuildMD5ByFile(filePath)); } string filePath2 = ABHelper.GetFileFolderPath(filePath); if (!CurVersionDependenciesList.ContainsKey(filePath2)) { CurVersionDependenciesList.Add(filePath2, new List <string>()); CurVersionFileType.Add(filePath2, "0"); } CurVersionDependenciesList[filePath2].Add(filePath); } foreach (string path in luaPathList) { if (!path.EndsWith(".lua")) { continue; } string filePath = path.Replace("\\", "/"); if (!CurVersionMd5List.ContainsKey(filePath)) { CurVersionMd5List.Add(filePath, ABHelper.BuildMD5ByFile(filePath)); } if (!CurVersionDependenciesList.ContainsKey(filePath)) { CurVersionDependenciesList.Add(filePath, new List <string>()); CurVersionFileType.Add(filePath, "1"); } CurVersionDependenciesList[filePath].Add(filePath); } foreach (string path in fileBundlePathList) { if (!IsNeedFileRes(path)) { continue; } string filePath = path.Replace("\\", "/"); string[] dependPaths = AssetDatabase.GetDependencies(filePath); if (dependPaths.Length > 0) { CurVersionDependenciesList.Add(filePath, new List <string>(dependPaths)); CurVersionFileType.Add(filePath, "2"); foreach (string path1 in dependPaths) { if (!CurVersionMd5List.ContainsKey(path1)) { CurVersionMd5List.Add(path1, ABHelper.BuildMD5ByFile(path1)); } if (path1.Contains(ResFolder) && filePath != path1) { if (!CurVersionManifestList.ContainsKey(filePath)) { CurVersionManifestList.Add(filePath, new List <string>()); } CurVersionManifestList[filePath].Add(path1); } } } } foreach (string path in sceneBundlePathList) { if (!path.EndsWith(".unity")) { continue; } string filePath = path.Replace("\\", "/"); string[] dependPaths = AssetDatabase.GetDependencies(filePath); if (dependPaths.Length > 0) { CurVersionDependenciesList.Add(filePath, new List <string>(dependPaths)); CurVersionFileType.Add(filePath, "3"); foreach (string path1 in dependPaths) { if (!CurVersionMd5List.ContainsKey(path1)) { CurVersionMd5List.Add(path1, ABHelper.BuildMD5ByFile(path1)); } if (path1.Contains(ResFolder) && filePath != path1) { if (!CurVersionManifestList.ContainsKey(filePath)) { CurVersionManifestList.Add(filePath, new List <string>()); } CurVersionManifestList[filePath].Add(path1); } } } } // 版本所需资源的md5码保存 ABHelper.WriteMd5File(CurVersionABExportPath + ABHelper.Md5FileName, CurVersionMd5List); // 文件的依赖关系 ABHelper.WriteDependFile(CurVersionABExportPath + ABHelper.DependFileName, CurVersionDependenciesList); }