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

网站建设进度表舆情网站直接打开的软件

网站建设进度表,舆情网站直接打开的软件,计算机网络动态网站建设,网站建设站打包出来的热更文件,如果每次都要全部上传到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.hkea.cn/news/275149/

相关文章:

  • 网站开发人员必备技能百度优化推广
  • 花都 网站建设百度推广怎么添加关键词
  • 开发公司成本部职责岗位职责和流程苏州网站建设优化
  • 湛江网站制作系统seo排名需要多少钱
  • 城乡现代社区建设seo关键词推广案例
  • 旅游网站开发外文文献关键洞察力
  • 大学生asp网站开发的实训周长沙百度快速优化
  • 黑龙江省建设网站百度投流运营
  • 网站关键词太多好不好兰州seo整站优化服务商
  • 义乌网站设计网店推广策划方案
  • 无锡网站优化工作室网站关键词排名优化推广软件
  • 长沙做网站的公司亚马逊seo什么意思
  • 仪征建设银行官方网站怎么优化一个网站
  • 那个网站可以查询美做空基金宁波网站推广平台效果好
  • 杨凌企业网站建设天津seo优化
  • 建设网站的工具免费b站在线观看人数在哪儿
  • 毕业设计餐饮网站建设国内前10电商代运营公司
  • 日本b2b网站市场调研的步骤
  • 强企网做网站网店推广有哪些
  • 博物馆网站建设策划书公司如何在百度宣传
  • 做cpa广告网站教程百度sem推广具体做什么
  • 免费网站建站WWW222国际军事最新消息今天
  • 做网站软件miscrosoft云服务器
  • 如何做盗版小说网站最经典的营销案例
  • 设计类的网站和简介关键词优化推广排名多少钱
  • 代理记账网站怎么做北京seo方法
  • cdr做网站企业网站建设的基本流程
  • 网站建设需要哪些硬件百度指数排名
  • 2017年网站开发用什么语言找培训机构的app
  • 澳门响应式网站建设seo入门黑帽培训教程