当前位置: 首页 > news >正文

学校网站设计sem优化软件选哪家

学校网站设计,sem优化软件选哪家,在哪个网站可以搜画画做品,营销推广的特点打包出来的热更文件,如果每次都要全部上传到CDN文件服务器,不进耗费时间长,还浪费流量。 所以让AI写了个简单的文件比较工具类,然后修改了一下可用。记录一下。 路径可自行更改。校验算法这里使用的是MD5,如果使用SH…

打包出来的热更文件,如果每次都要全部上传到CDN文件服务器,不进耗费时间长,还浪费流量。

所以让AI写了个简单的文件比较工具类,然后修改了一下可用。记录一下。

路径可自行更改。校验算法这里使用的是MD5,如果使用SHA256校验,时间会长达1分钟,MD5只有5秒左右。一般用MD5即可。同步拷贝的写法时间太长,改为异步拷贝的写法,时间减半,只需30秒和3秒。(项目的热更文件67个,总大小在700M左右)

代码如下,放到Assets/Editor/路径下即可。
 

using System;
using System.IO;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using UnityEditor;/// <summary>
/// 比较热更文件的差异 拷贝到另一个文件夹
/// </summary>
public class HotfixComparerAsync
{
#if UNITY_ANDROIDstatic string SourceFolder = Application.dataPath + "/../ServerData/Android"; // 源文件夹路径static string TargetFolder = Application.dataPath + "/../ServerData/Android_server"; // 目标文件夹路径static string OutputFolder = Application.dataPath + "/../ServerData/Android_hotfix"; // 输出文件夹路径,存放复制的文件
#endif
#if UNITY_IOSstatic string SourceFolder = Application.dataPath + "/../ServerData/iOS"; // 源文件夹路径static string TargetFolder = Application.dataPath + "/../ServerData/iOS_server"; // 目标文件夹路径static string OutputFolder = Application.dataPath + "/../ServerData/iOS_hotfix"; // 输出文件夹路径,存放复制的文件
#endif
#if UNITY_STANDALONE_WINstatic string SourceFolder = Application.dataPath + "/../ServerData/StandaloneWindows64"; // 源文件夹路径static string TargetFolder = Application.dataPath + "/../ServerData/StandaloneWindows64_server"; // 目标文件夹路径static string OutputFolder = Application.dataPath + "/../ServerData/StandaloneWindows64_hotfix"; // 输出文件夹路径,存放复制的文件
#endif[MenuItem("Tools/比较并拷贝热更文件Async")]public static void CompareAndCopyFiles(){DateTime startTime = DateTime.Now;if (!Directory.Exists(OutputFolder)){Directory.CreateDirectory(OutputFolder);}var sourceFiles = new HashSet<string>(Directory.GetFiles(SourceFolder, "*.*", SearchOption.AllDirectories));var targetFilesHashes = new Dictionary<string, string>();foreach (var file in Directory.GetFiles(TargetFolder, "*.*", SearchOption.AllDirectories)){string relativePath = MakeRelativePath(file, TargetFolder);targetFilesHashes[relativePath] = FileHash(file);}var tasks = new List<Task>();foreach (var sourceFile in sourceFiles){string relativePath = MakeRelativePath(sourceFile, SourceFolder);tasks.Add(Task.Run(() => ProcessFile(sourceFile, relativePath, targetFilesHashes)));}Task.WhenAll(tasks.ToArray()).Wait();TimeSpan diff = DateTime.Now - startTime;Debug.Log($"比较完成耗费:{diff.Minutes}分{diff.Seconds}秒");}private static void ProcessFile(string sourceFile, string relativePath, Dictionary<string, string> targetFilesHashes){if (targetFilesHashes.ContainsKey(relativePath)){string hash = FileHash(sourceFile);if (targetFilesHashes[relativePath] != hash){CopyFile(sourceFile, Path.Combine(OutputFolder, relativePath));}}else{CopyFile(sourceFile, Path.Combine(OutputFolder, relativePath));}}private static string MakeRelativePath(string path, string rootDirectory){return path.Substring(rootDirectory.Length + 1);}private static string FileHash(string file){using (var stream = File.OpenRead(file)){using (var hash = MD5.Create()){byte[] hashBytes = hash.ComputeHash(stream);return BitConverter.ToString(hashBytes).Replace("-", "").ToLowerInvariant();}}}private static void CopyFile(string sourceFile, string targetFile){//File.Copy(sourceFile, targetFile, true);// 获取目标文件的目录路径string targetDirectory = Path.GetDirectoryName(targetFile);// 如果目标目录不存在,则创建它if (!Directory.Exists(targetDirectory)){Directory.CreateDirectory(targetDirectory);}try{// 尝试复制文件File.Copy(sourceFile, targetFile, true);}catch (Exception e){// 处理可能的异常Debug.LogError($"Failed to copy file from {sourceFile} to {targetFile}. Error: {e.Message}");}}
}

http://www.yayakq.cn/news/237819/

相关文章:

  • 天津网站建设推荐安徽秒搜科技wordpress自定义模块自定义字段
  • 广西建设部投诉网站做网站的详细流程
  • 网站模板和定制山东鲁为建设集团网站
  • 首页有动效的网站沈阳室内设计公司排名
  • 淘宝购物券网站怎么做wordpress拉宽
  • 金融棋牌网站建设WordPress更新时间
  • 发明迷网站豆渣做豆腐网站建设制作公司
  • 平度网站建设ld4怎么给网站备案
  • 建设门户公司网站常见购物网站功能
  • 免费个人网站申请wordpress 微信内登录
  • 正规招聘网站有哪些眉山网站设计
  • 网站建设开发服务费怎么做分录芜湖比较出名的企业
  • 网站建设公司落寞wordpress 前台写文章
  • 营销网站seo推广费用做地方门户网站赚钱吗
  • 个人网站快速备案代理公司招标流程
  • 郴州网站建设较好的公司电子商务的应用场景
  • 网站服务器ip建设网站都需要哪些
  • 台州平台网站建设常用的网络推广手段有哪些
  • 邢台中高风险地区查询seo推广优化平台
  • 怎样会展网站建设有哪些可以做宣传旅游的网站
  • 创业网站模板海洋网络提供网站建设
  • 网站建设所要花费的资金网络公司主要经营哪些业务
  • 做快递单的网站会不会是骗人的营销型网站建设的利与弊
  • 河北省住房和城乡建设局网站福州小程序开发公司列表
  • 公司设计网站有什么好处wordpress标签评论
  • 东莞好的网站国外站建设价格项目设计方案
  • 网站建设报价 下载图片识别
  • 做淘宝那样的网站要多少钱做网站模板用什么框架
  • 网站建设需要注意的事情提供邢台专业做网站
  • 深圳市南山区网站建设国家建设局