Skip to content

Commit

Permalink
separate compress and decompress logic as a new crate and add it as d…
Browse files Browse the repository at this point in the history
…ependency
  • Loading branch information
uncomfyhalomacro committed Sep 7, 2024
1 parent a3b5d3e commit 2dbe19f
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 510 deletions.
538 changes: 286 additions & 252 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ default-members = [
resolver = "2"

[workspace.package]
version = "1.3.5"
version = "1.4.0"
description = "OBS Source Service and utilities for Rust software packaging."
authors = [
"Soc Virnyl Estela <socvirnyl.estela@uncomfyhalomacro.pl>",
Expand Down
1 change: 1 addition & 0 deletions cargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ xz2 = "0.1"
zstd = { version = "0.12", features = ["pkg-config", "zstdmt"] }
bzip2 = { version = "0.4" }
walkdir = "2.4"
libroast = { git = "https://github.com/openSUSE-Rust/roast", version = "1.1.1" }

[lints]
workspace = true
9 changes: 5 additions & 4 deletions cargo/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::utils;

use clap::{Parser, ValueEnum};
use infer;
use libroast::decompress;

#[allow(unused_imports)]
use tracing::{debug, error, info, trace, warn, Level};
Expand Down Expand Up @@ -157,10 +158,10 @@ pub trait Vendor {

pub fn decompress(comp_type: &Compression, outdir: &Path, src: &Path) -> io::Result<()> {
match comp_type {
Compression::Gz => utils::decompress::targz(outdir, src),
Compression::Xz => utils::decompress::tarxz(outdir, src),
Compression::Zst => utils::decompress::tarzst(outdir, src),
Compression::Bz2 => utils::decompress::tarbz2(outdir, src),
Compression::Gz => decompress::targz(outdir, src),
Compression::Xz => decompress::tarxz(outdir, src),
Compression::Zst => decompress::tarzst(outdir, src),
Compression::Bz2 => decompress::tarbz2(outdir, src),
}
}

Expand Down
164 changes: 0 additions & 164 deletions cargo/src/utils/compress.rs

This file was deleted.

81 changes: 0 additions & 81 deletions cargo/src/utils/decompress.rs

This file was deleted.

3 changes: 0 additions & 3 deletions cargo/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// SPDX-License-Identifier: MPL-2.0

pub mod compress;
pub mod decompress;

use std::ffi::OsStr;
use std::fmt::{self, Debug, Display};
use std::fs;
Expand Down
10 changes: 5 additions & 5 deletions cargo/src/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::cli::Compression;
use crate::errors::OBSCargoError;
use crate::errors::OBSCargoErrorKind;
use crate::utils::cargo_command;
use crate::utils::compress;
use libroast::compress;

use serde::Deserialize;
use serde::Serialize;
Expand Down Expand Up @@ -204,7 +204,7 @@ pub fn compress(
"🔦 Compressed tarball for vendor exists AND will be replaced."
);
}
compress::targz(&vendor_out, &prjdir, paths_to_archive).map_err(|err| {
compress::targz(&vendor_out, &prjdir, paths_to_archive, true).map_err(|err| {
error!(?err, "gz compression failed");
OBSCargoError::new(
OBSCargoErrorKind::VendorCompressionFailed,
Expand All @@ -221,7 +221,7 @@ pub fn compress(
"🔦 Compressed tarball for vendor exists AND will be replaced."
);
}
compress::tarxz(&vendor_out, &prjdir, paths_to_archive).map_err(|err| {
compress::tarxz(&vendor_out, &prjdir, paths_to_archive, true).map_err(|err| {
error!(?err, "xz compression failed");
OBSCargoError::new(
OBSCargoErrorKind::VendorCompressionFailed,
Expand All @@ -238,7 +238,7 @@ pub fn compress(
"🔦 Compressed tarball for vendor exists AND will be replaced."
);
}
compress::tarzst(&vendor_out, &prjdir, paths_to_archive).map_err(|err| {
compress::tarzst(&vendor_out, &prjdir, paths_to_archive, true).map_err(|err| {
error!(?err, "zst compression failed");
OBSCargoError::new(
OBSCargoErrorKind::VendorCompressionFailed,
Expand All @@ -255,7 +255,7 @@ pub fn compress(
"🔦 Compressed tarball for vendor exists AND will be replaced."
);
}
compress::tarbz2(&vendor_out, &prjdir, paths_to_archive).map_err(|err| {
compress::tarbz2(&vendor_out, &prjdir, paths_to_archive, true).map_err(|err| {
error!(?err, "bz2 compression failed");
OBSCargoError::new(
OBSCargoErrorKind::VendorCompressionFailed,
Expand Down

0 comments on commit 2dbe19f

Please sign in to comment.