Skip to content

Commit

Permalink
Simplify file operations
Browse files Browse the repository at this point in the history
  • Loading branch information
szeweq committed Jun 1, 2024
1 parent dbe7120 commit 7f6478b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
14 changes: 4 additions & 10 deletions lib-core/src/fop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashSet;

use crate::{min::{Minifier, only_recompress}, errors::FileIgnoreError};
use crate::{min::Minifier, errors::FileIgnoreError};

/// A file operation needed before a file is saved in repacked archive
pub enum FileOp {
Expand Down Expand Up @@ -31,16 +31,10 @@ impl FileOp {
let Some((_, ftype)) = fname.rsplit_once('.') else {
return Self::Pass
};
if ftype == "class" {
return Self::Recompress(64)
if blacklist.can_ignore(ftype) {
return Self::Ignore(FileIgnoreError::Blacklisted)
}
if only_recompress(ftype) {
return Self::Recompress(8)
}
if let Some(x) = Minifier::by_extension(ftype) {
return Self::Minify(x)
}
if blacklist.can_ignore(ftype) { Self::Ignore(FileIgnoreError::Blacklisted) } else { Self::Pass }
Minifier::by_extension(ftype).map_or(Self::Pass, Self::Minify)
}
}

Expand Down
7 changes: 0 additions & 7 deletions lib-core/src/min/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ fn find_brackets(b: &[u8]) -> Option<(usize, usize)> {
Some((i, j))
}

/// Checks if a file can be recompressed (not minified) depending on its extension
#[must_use]
pub fn only_recompress(ftype: &str) -> bool {
matches!(ftype, "glsl" | "html" | "kotlin_module" | "md" | "txt" | "vert" | "xml")
}


/// A type to determine a minifying method and minimum compress size for file data.
pub enum Minifier {
/// A PNG minifier using `oxipng`.
Expand Down

0 comments on commit 7f6478b

Please sign in to comment.