Skip to content

Commit

Permalink
Replace older entries by default
Browse files Browse the repository at this point in the history
  • Loading branch information
schneems committed Jul 24, 2024
1 parent 5d39fdc commit 2c4b20d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
34 changes: 20 additions & 14 deletions jruby_executable/src/bin/jruby_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,30 @@ fn jruby_build(args: &Args) -> Result<(), Box<dyn Error>> {
let timestamp = chrono::Utc::now();
for cpu_arch in &[CpuArch::new("amd64")?, CpuArch::new("arm64")?] {
let distro_version = base_image.distro_version();

let artifact = Artifact {
version: GemVersion::from_str(version)?,
os: inventory::artifact::Os::Linux,
arch: cpu_arch.try_into()?,
url: format!(
"{S3_BASE_URL}/{}",
sha_seven_path.strip_prefix(&volume_output_dir)?.display()
),
checksum: format!("sha256:{sha}").parse()?,
metadata: ArtifactMetadata {
distro_version,
timestamp,
},
};
atomic_file_contents(&inventory, |file, contents| {
let mut inventory = parse_inventory(contents)?;
inventory.push(Artifact {
version: GemVersion::from_str(version)?,
os: inventory::artifact::Os::Linux,
arch: cpu_arch.try_into()?,
url: format!(
"{S3_BASE_URL}/{}",
sha_seven_path.strip_prefix(&volume_output_dir)?.display()
),
checksum: format!("sha256:{sha}").parse()?,
metadata: ArtifactMetadata {
distro_version,
timestamp,
},
inventory.artifacts.retain(|a| {
a.version != artifact.version
|| a.arch != artifact.arch
|| a.metadata.distro_version != artifact.metadata.distro_version
});

inventory.push(artifact);

writeln!(file, "{inventory}").expect("Writeable file");

Ok(())
Expand Down
9 changes: 4 additions & 5 deletions shared/src/inventory_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ use crate::base_image::DistroVersion;
use crate::{download_tar, Error, TarDownloadPath};
use chrono::{DateTime, Utc};
use fs2::FileExt;
use fs_err::os::unix::fs;
use gem_version::GemVersion;
use inventory::artifact::Artifact;
use inventory::checksum::Checksum;
use inventory::inventory::Inventory;
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
use sha2::Sha256;
use std::borrow::Borrow;
use std::io::{Read, Seek, Write};
use std::io::Read;
use std::path::Path;

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down Expand Up @@ -169,9 +167,10 @@ where

#[cfg(test)]
mod test {
use std::str::FromStr;

use crate::BaseImage;
use inventory::artifact::Artifact;
use std::io::Write;
use std::str::FromStr;

use super::*;

Expand Down

0 comments on commit 2c4b20d

Please sign in to comment.