Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas-Heiligenbrunner committed Aug 18, 2024
1 parent b73c5ec commit 3405dac
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions backend/src/builder/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use crate::db::prelude::{Builds, Files, PackagesFiles};
use crate::db::{builds, files, packages, packages_files};
use crate::repo::utils::try_remove_archive_file;
use anyhow::anyhow;
use bollard::container::{AttachContainerOptions, Config, CreateContainerOptions, KillContainerOptions, LogOutput, RemoveContainerOptions};
use bollard::container::{
AttachContainerOptions, Config, CreateContainerOptions, KillContainerOptions, LogOutput,
RemoveContainerOptions,
};
use bollard::image::CreateImageOptions;
use bollard::models::{ContainerCreateResponse, HostConfig};
use bollard::Docker;
Expand All @@ -25,6 +28,8 @@ use std::{env, fs};
use tokio::sync::Mutex;
use tokio::time::timeout;

static BUILDER_IMAGE: &str = "docker.io/greyltc/archlinux-aur:paru";

pub(crate) async fn cancel_build(
build_id: i32,
job_containers: Arc<Mutex<HashMap<i32, String>>>,
Expand Down Expand Up @@ -170,7 +175,9 @@ pub async fn build(
.append(format!("Build #{build_id} timed out for package '{name}'"))
.await?;
// kill build container
docker.kill_container(&id, Some(KillContainerOptions{signal: "SIGKILL"})).await?;
docker
.kill_container(&id, Some(KillContainerOptions { signal: "SIGKILL" }))
.await?;
}
}

Expand Down Expand Up @@ -215,12 +222,12 @@ async fn monitor_build_output(
LogOutput::Console { .. } => unreachable!(),
LogOutput::StdOut { message } => {
build_logger
.append(String::from_utf8(Vec::from(message)).unwrap())
.append(String::from_utf8_lossy(&message).into_owned())
.await?
}
LogOutput::StdErr { message } => {
build_logger
.append(String::from_utf8(Vec::from(message)).unwrap())
.append(String::from_utf8_lossy(&message).into_owned())
.await?
}
},
Expand Down Expand Up @@ -252,7 +259,7 @@ async fn create_build_container(

let container_name = format!("aurcache_build_{}_{}", name, build_id);
let conf = Config {
image: Some("docker.io/greyltc/archlinux-aur:paru"),
image: Some(BUILDER_IMAGE),
attach_stdout: Some(true),
attach_stderr: Some(true),
open_stdin: Some(false),
Expand Down Expand Up @@ -344,7 +351,7 @@ async fn repull_image(docker: &Docker, build_logger: &BuildLogger) -> anyhow::Re
// repull image to make sure it's up to date
let mut stream = docker.create_image(
Some(CreateImageOptions {
from_image: "docker.io/greyltc/archlinux-aur:paru",
from_image: BUILDER_IMAGE,
..Default::default()
}),
None,
Expand Down

0 comments on commit 3405dac

Please sign in to comment.