From d6e7879cf89da8b6ed1088235c83dd06016f7f26 Mon Sep 17 00:00:00 2001 From: Cno Date: Tue, 6 Aug 2024 00:06:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8D=95=E6=B5=8B?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compression/tar.rs | 5 +++-- src/entrances/update.rs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compression/tar.rs b/src/compression/tar.rs index 6767f531..cbd020de 100644 --- a/src/compression/tar.rs +++ b/src/compression/tar.rs @@ -1,4 +1,4 @@ -use anyhow::Result; +use anyhow::{anyhow, Result}; use std::fs::{create_dir_all, remove_dir_all, File}; use std::path::Path; use tar::{Archive, Builder}; @@ -19,7 +19,8 @@ pub fn release_tar(source: &String, into: &String) -> Result<()> { } pub fn pack_tar(source: &String, store_at: &String) -> Result<()> { - let file = File::create(store_at)?; + let file = File::create(store_at) + .map_err(|e| anyhow!("Error:Failed to create file at '{store_at}' : {e}"))?; let mut archive = Builder::new(file); archive.append_dir_all(".", source)?; archive.finish()?; diff --git a/src/entrances/update.rs b/src/entrances/update.rs index d1071b49..319be392 100644 --- a/src/entrances/update.rs +++ b/src/entrances/update.rs @@ -324,15 +324,16 @@ fn test_update_all() { // 生成新包 crate::utils::fs::copy_dir("examples/VSCode", "test/VSCode").unwrap(); crate::utils::test::_modify_installed_package_version("test/VSCode", "1.75.4.2"); + std::fs::create_dir("test/static").unwrap(); crate::pack( &"./test/VSCode".to_string(), - Some("./test/VSCode_1.75.4.2_Cno.nep".to_string()), + Some("./test/static/VSCode_1.75.4.2_Cno.nep".to_string()), false, ) .unwrap(); crate::pack( &"./examples/Notepad".to_string(), - Some("./test/Notepad_22.1.0.0_Cno.nep".to_string()), + Some("./test/static/Notepad_22.1.0.0_Cno.nep".to_string()), false, ) .unwrap();