Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiny code refactor #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/service/build/run_prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions src/service/proxy/package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ pub async fn run(request: Request<PackageRequest>) -> Result<Response<PackageRes
async fn prepare_source<P: AsRef<Path>>(
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?;

Expand Down
8 changes: 6 additions & 2 deletions src/store/archives.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<P1, P2>(target_dir: P1, source_tar: P2) -> Result<(), anyhow::Error>
where
P1: AsRef<Path>,
P2: AsRef<Path>,
{
let tar_gz = File::open(source_tar).await?;
let buf_reader = BufReader::new(tar_gz);
let gz_decoder = GzipDecoder::new(buf_reader);
Expand Down