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

建设静态网站wordpress post下载

建设静态网站,wordpress post下载,WordPress评论第页,安居网站建设在使用actix-web框架的时候#xff0c;如果使用zip解压任务将会占用一个工作线程#xff0c;因为zip库是同步阻塞的#xff0c;想用异步非阻塞需要用另一个库#xff0c;下面列出同步解压#xff0c;跟异步解压的两个方法实现#xff0c;异步解压不会占用工作线程。 阻塞… 在使用actix-web框架的时候如果使用zip解压任务将会占用一个工作线程因为zip库是同步阻塞的想用异步非阻塞需要用另一个库下面列出同步解压跟异步解压的两个方法实现异步解压不会占用工作线程。 阻塞解压 依赖库 zip 0.6.6rust代码 pub fn unzipP: AsRefstd::path::Path(file_path: P,unzip_path: P, ) - Result(), std::io::Error {let file_path file_path.as_ref();let unzip_path unzip_path.as_ref();let unzip_path std::path::Path::new(unzip_path);if unzip_path.exists() {std::fs::remove_dir_all(unzip_path)?;} else {std::fs::create_dir_all(unzip_path)?;}let file std::fs::File::open(file_path)?;let mut archive zip::ZipArchive::new(file)?;for index in 0..archive.len() {let mut file archive.by_index(index)?;let file_name file.mangled_name();let outpath unzip_path.join(file_name);if file.is_dir() {std::fs::create_dir_all(outpath)?;} else {if let Some(p) outpath.parent() {if !p.exists() {std::fs::create_dir_all(p)?;}}let mut outfile std::fs::File::create(outpath)?;std::io::copy(mut file, mut outfile)?;}}return Ok(()); }异步解压 依赖库 async_zip { version 0.0.17, features [tokio, tokio-fs, deflate] } futures-lite 2.3.0 tokio { version 1.35.1, features [macros] } tokio-util 0.7.10rust代码 use async_zip::base::read::seek::ZipFileReader; use async_zip::base::write::ZipFileWriter; use async_zip::ZipEntryBuilder; use tokio::fs::OpenOptions; use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};pub async fn unzip_asyncP: AsRefstd::path::Path(file_path: P,unzip_path: P, ) - Result(), ApiError {let unzip_path unzip_path.as_ref();if unzip_path.exists() {std::fs::remove_dir_all(unzip_path)?;} else {std::fs::create_dir_all(unzip_path)?;}let file tokio::fs::File::open(file_path.as_ref()).await?;let reader tokio::io::BufReader::new(file);let mut zip ZipFileReader::with_tokio(reader).await.map_err(ApiError::from)?;for index in 0..zip.file().entries().len() {let entry zip.file().entries().get(index).ok_or(ApiError::msg(zip entry not found))?;let raw entry.filename().as_bytes();let mut file_name String::from_utf8_lossy(raw).to_string(); //必需转换为utf8不能使用自带的会乱码let outpath unzip_path.join(file_name);if file_name.ends_with(/) {tokio::fs::create_dir_all(outpath).await?;} else {if let Some(p) outpath.parent() {if !p.exists() {tokio::fs::create_dir_all(p).await?;}}let mut entry_reader zip.reader_without_entry(index).await.map_err(ApiError::from)?;let mut writer OpenOptions::new().write(true).create_new(true).open(outpath).await.map_err(ApiError::from)?;futures_lite::io::copy(mut entry_reader, mut writer.compat_write()).await?;}}Ok(()) }
http://www.pierceye.com/news/553914/

相关文章:

  • 传媒网站建设方案wordpress开源博客系统最新版
  • 三合一网站一般多少钱浙江省和住房建设厅网站
  • 网站开发背景知识论文网页设计表格
  • 广州优秀网站建设怎么寻找国外客户资源
  • 松江新城投资建设集团有限公司网站华能电子商务平台
  • 网站建设设计制作公司微网站微商城
  • 长宁企业网站建设个人做外贸怎么做
  • 饲料 东莞网站建设免费推广app
  • 手机平台网站开发品牌网站设计首选
  • 哪些网站可以做调查赚钱图片生成软件
  • 网站空间的管理wordpress vip system
  • 新思维网站北京住房建设部网站首页
  • 温州网站制作套餐麒麟网站建设
  • 淘宝接单做网站wordpress能做企业网站吗
  • 网站建设运营公众号运营合同app网站开发书籍下载
  • 网站seo流程网站开发开账务处理
  • 婚介网站方案长沙网络公司电话
  • 自助网站搭建系统做网站接电话一般要会什么
  • 雷州网站建设公司网站建设与管理说课ppt
  • 问答类网站怎么做wordpress 调取页面缩略图
  • 做电影资源网站手机版wordpress实例配置
  • 广西网站建设方案品牌官网方案
  • 游戏工作室网络组建方案seo81
  • 搭建个人网站的步骤温州专业微网站制作价格
  • 网站怎么做充值系统php图书管理系统网站开发
  • 多商家网站建设自助建站系统源码 资源网
  • 广州番禺网站制作公司哪家好文章网站建设
  • 漯河网站建设e辽宁身营商环境建设局网站
  • 营销网站建设套餐企业信息公示管理系统
  • 网站布局设计排版网站外部链接做多少合适呢