From 0f24269e560f7ca03a64a8d113c37d5a3b92c28f Mon Sep 17 00:00:00 2001 From: Brian Spit Date: Sun, 9 Jun 2024 21:53:57 +0200 Subject: [PATCH 1/3] Package_source_tar_path can be referenced --- src/service/build/run_prepare.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/build/run_prepare.rs b/src/service/build/run_prepare.rs index 14fe19e7..f9e8a30d 100644 --- a/src/service/build/run_prepare.rs +++ b/src/service/build/run_prepare.rs @@ -87,7 +87,7 @@ pub async fn run( let metadata = fs::metadata(&package_source_tar_path).await?; let mut permissions = metadata.permissions(); permissions.set_mode(0o444); - fs::set_permissions(package_source_tar_path.clone(), permissions).await?; + fs::set_permissions(&package_source_tar_path, permissions).await?; let file_name = package_source_tar_path.file_name().unwrap(); info!("source tar created: {}", file_name.to_string_lossy()); } From 0d95b1a47dda68497e2eeb425847eb3d0b979bab Mon Sep 17 00:00:00 2001 From: Brian Spit Date: Sun, 9 Jun 2024 21:58:56 +0200 Subject: [PATCH 2/3] Use generics for Path and PathBuf These changes were lost in the last merge --- src/store/archives.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/store/archives.rs b/src/store/archives.rs index 2ce3ebee..b48c0bbb 100644 --- a/src/store/archives.rs +++ b/src/store/archives.rs @@ -1,6 +1,6 @@ use anyhow::Result; use async_compression::tokio::{bufread::GzipDecoder, write::GzipEncoder}; -use std::path::{Path, PathBuf}; +use std::path::Path; use tokio::fs::File; use tokio::io::AsyncWriteExt; use tokio::io::BufReader; @@ -50,7 +50,11 @@ where Ok(output.into_inner()) } -pub async fn unpack_tar_gz(target_dir: &PathBuf, source_tar: &Path) -> Result<(), anyhow::Error> { +pub async fn unpack_tar_gz(target_dir: P1, source_tar: P2) -> Result<(), anyhow::Error> +where + P1: AsRef, + P2: AsRef, +{ let tar_gz = File::open(source_tar).await?; let buf_reader = BufReader::new(tar_gz); let gz_decoder = GzipDecoder::new(buf_reader); From e4927d6340a9c556d4d84cc45d31bc44dbd164cc Mon Sep 17 00:00:00 2001 From: Brian Spit Date: Sun, 9 Jun 2024 22:02:18 +0200 Subject: [PATCH 3/3] Reference can be moved to body --- src/service/proxy/package/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service/proxy/package/mod.rs b/src/service/proxy/package/mod.rs index 417e1bd8..f39af615 100644 --- a/src/service/proxy/package/mod.rs +++ b/src/service/proxy/package/mod.rs @@ -56,9 +56,9 @@ pub async fn run(request: Request) -> Result>( source_name: &str, source_hash: &str, - source_tar: &P, + source_tar: P, ) -> Result<(i32, String), anyhow::Error> { - let data = read(source_tar).await?; + let data = read(&source_tar).await?; let signature = notary::sign(&data).await?;