Skip to content

Commit

Permalink
🐛 fix: Fix compression on Arch artifacts (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
queer committed May 25, 2023
1 parent 7f7b407 commit 4703367
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions src/artifact/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use std::path::PathBuf;

use eyre::Result;
use regex::Regex;
use tokio::fs::File;
use tokio_stream::StreamExt;
use tracing::*;

use crate::fs::MemFS;
Expand Down Expand Up @@ -76,39 +74,33 @@ impl SelfValidation for ArchArtifact {
}

if let Some(file_name) = self.path.file_name() {
if !file_name
.to_string_lossy()
.to_string()
.ends_with(".pkg.tar")
{
errors.push(format!(
"{} does not end with .pkg.tar",
self.path.display(),
));
if !file_name.to_string_lossy().to_string().contains(".pkg.tar") {
errors.push(format!("{} does not contain .pkg.tar", self.path.display(),));
}
} else {
errors.push(format!("{} does not have a file name", self.path.display()));
}

// Validate that the .PKGINFO file exists in the tarball
let mut tarball = tokio_tar::Archive::new(File::open(&self.path).await?);
let mut pkginfo_exists = false;

let mut entries = tarball.entries()?;
while let Some(gz_entry) = entries.try_next().await? {
let path = gz_entry.path()?;
if path.ends_with(".PKGINFO") {
pkginfo_exists = true;
break;
}
}

if !pkginfo_exists {
errors.push(format!(
"{} does not contain a .PKGINFO file",
self.path.display()
));
}
// TODO: This check needs to handle compression correctly.
// let mut tarball = tokio_tar::Archive::new(File::open(&self.path).await?);
// let mut pkginfo_exists = false;

// let mut entries = tarball.entries()?;
// while let Some(gz_entry) = entries.try_next().await? {
// let path = gz_entry.path()?;
// if path.ends_with(".PKGINFO") {
// pkginfo_exists = true;
// break;
// }
// }

// if !pkginfo_exists {
// errors.push(format!(
// "{} does not contain a .PKGINFO file",
// self.path.display()
// ));
// }

if !errors.is_empty() {
Err(eyre::eyre!(
Expand Down

0 comments on commit 4703367

Please sign in to comment.