Esempio n. 1
0
        public static string GetBundleMD5(VersionConfig streamingVersionConfig, string bundleName)
        {
            string path = Path.Combine(PathHelper.AppHotfixResPath, bundleName);

            if (File.Exists(path))
            {
                return(MD5Helper.FileMD5(path));
            }

            if (streamingVersionConfig.FileInfoDict.ContainsKey(bundleName))
            {
                return(streamingVersionConfig.FileInfoDict[bundleName].MD5);
            }

            return("");
        }
Esempio n. 2
0
        /// <summary>
        /// 获取本地AB包MD5值
        /// </summary>
        /// <param name="streamingVersionConfig"></param>
        /// <param name="bundleName"></param>
        /// <returns></returns>
        public static string GetBundleMD5(VersionConfig streamingVersionConfig, string bundleName)
        {
            //如果本地有这个AB包 就生成MD5值返回
            string path = Path.Combine(PathHelper.AppHotfixResPath, bundleName);

            if (File.Exists(path))
            {
                return(MD5Helper.FileMD5(path));
            }
            //如果没有,就看看本地Version中是否有这个文件的的MD5值
            if (streamingVersionConfig.FileInfoDict.ContainsKey(bundleName))
            {
                return(streamingVersionConfig.FileInfoDict[bundleName].MD5);
            }
            //否则就返回空
            return("");
        }
Esempio n. 3
0
        public static void ExportAll(string exportDirectory, bool forceRegenerate = true)
        {
            if (!Directory.Exists(exportDirectory))
            {
                Directory.CreateDirectory(exportDirectory);
            }

            string md5File = Path.Combine(ExcelPath, "md5.txt");
            if (!File.Exists(md5File))
            {
                md5Info = new ExcelMD5Info();
            }
            else
            {
                md5Info = JsonHelper.FromJson<ExcelMD5Info>(File.ReadAllText(md5File));
            }

            string[] files = Directory.GetFiles(ExcelPath);
            foreach (string filePath in files)
            {
                if (filePath.Length < 12 || Path.GetFileName(filePath).StartsWith("~") || !filePath.EndsWith("Config.xlsx"))
                {
                    continue;
                }
                string fileName = Path.GetFileName(filePath);
                string oldMD5 = md5Info.Get(fileName);
                string md5 = MD5Helper.FileMD5(filePath);
                md5Info.Add(fileName, md5);
                if (md5 == oldMD5 && !forceRegenerate)
                {
                    continue;
                }

                Export(filePath, exportDirectory);
            }

            File.WriteAllText(md5File, JsonHelper.ToJson(md5Info));
        }
Esempio n. 4
0
        private static void GenerateVersionProto(string dir, VersionConfig versionProto, string relativePath)
        {
            foreach (string file in Directory.GetFiles(dir))
            {
                string   md5      = MD5Helper.FileMD5(file);
                FileInfo fi       = new FileInfo(file);
                long     size     = fi.Length;
                string   filePath = relativePath == "" ? fi.Name : $"{relativePath}/{fi.Name}";

                versionProto.FileInfoDict.Add(filePath, new FileVersionInfo
                {
                    File = filePath,
                    MD5  = md5,
                    Size = size,
                });
            }

            foreach (string directory in Directory.GetDirectories(dir))
            {
                DirectoryInfo dinfo = new DirectoryInfo(directory);
                string        rel   = relativePath == "" ? dinfo.Name : $"{relativePath}/{dinfo.Name}";
                GenerateVersionProto($"{dir}/{dinfo.Name}", versionProto, rel);
            }
        }