Skip to content

Commit

Permalink
release: 3.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Sep 12, 2024
2 parents e26ee4f + ea19162 commit e5f1c80
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 9 deletions.
7 changes: 4 additions & 3 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project Dependencies
Package: flaca
Version: 3.1.7
Generated: 2024-09-06 03:07:10 UTC
Version: 3.1.8
Generated: 2024-09-12 18:28:44 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
Expand All @@ -19,7 +19,7 @@
| [dowser](https://github.com/Blobfolio/dowser) | 0.9.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [equivalent](https://github.com/cuviper/equivalent) | 1.0.1 | | Apache-2.0 or MIT |
| [fastrand](https://github.com/smol-rs/fastrand) | 2.1.1 | [Stjepan Glavina](mailto:[email protected]) | Apache-2.0 or MIT |
| flapfli | 3.1.7 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| flapfli | 3.1.8 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [funty](https://github.com/myrrlyn/funty) | 2.0.0 | [myrrlyn](mailto:[email protected]) | MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.14.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.14.5 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
Expand All @@ -38,6 +38,7 @@
| [tempfile](https://github.com/Stebalien/tempfile) | 3.12.0 | [Steven Allen](mailto:[email protected]), The Rust Project Developers, [Ashley Mannix](mailto:[email protected]), and [Jason White](mailto:[email protected]) | Apache-2.0 or MIT |
| [terminal_size](https://github.com/eminence/terminal-size) | 0.3.0 | [Andrew Chin](mailto:[email protected]) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.1.13 | [kwantam](mailto:[email protected]) and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.9.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [write_atomic](https://github.com/Blobfolio/write_atomic) | 0.5.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [wyz](https://github.com/myrrlyn/wyz) | 0.5.1 | [myrrlyn](mailto:[email protected]) | MIT |
| [zerocopy](https://github.com/google/zerocopy) | 0.7.35 | [Joshua Liebow-Feeser](mailto:[email protected]) | Apache-2.0, BSD-2-Clause, or MIT |
3 changes: 2 additions & 1 deletion flaca/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flaca"
version = "3.1.7"
version = "3.1.8"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand Down Expand Up @@ -118,6 +118,7 @@ ctrlc = "=3.4.5"
dactyl = "0.7.*"
dowser = "0.9.*"
libc = "0.2.*"
utc2k = "0.9.*"
write_atomic = "0.5.*"

[dependencies.flapfli]
Expand Down
2 changes: 2 additions & 0 deletions flaca/src/image/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ mod tests {
("../skel/assets/jpg/21.jpg", 720, 462),
("../skel/assets/jpg/22.jpg", 267, 150),
("../skel/assets/jpg/23.jpg", 330, 313),
("../skel/assets/jpg/24.jpg", 1076, 1500),
("../skel/assets/wolf.png", 600, 800),

// And because JPEGs are so weird, let's double-check our work
Expand Down Expand Up @@ -253,6 +254,7 @@ mod tests {
"../skel/assets/jpg/21.jpg" Some(ImageKind::Jpeg),
"../skel/assets/jpg/22.jpg" Some(ImageKind::Jpeg),
"../skel/assets/jpg/23.jpg" Some(ImageKind::Jpeg),
"../skel/assets/jpg/24.jpg" Some(ImageKind::Jpeg),
"../skel/assets/png/01.png" Some(ImageKind::Png),
"../skel/assets/png/02.png" Some(ImageKind::Png),
"../skel/assets/png/03.png" Some(ImageKind::Png),
Expand Down
57 changes: 55 additions & 2 deletions flaca/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ fn _main() -> Result<(), FlacaError> {
sigint(Arc::clone(&killed), progress.clone());

// Now onto the thread business!
let mut undone: Vec<&Path> = Vec::new(); // Skipped because of CTRL+C or tx fail.
let (tx, rx) = crossbeam_channel::bounded::<&Path>(threads.get());
thread::scope(#[inline(always)] |s| {
// Set up the worker threads, either with or without progress.
Expand All @@ -231,9 +232,32 @@ fn _main() -> Result<(), FlacaError> {
}
}

// Queue up all the image paths, unless CTRL+C is pressed.
// Queue up all the image paths!
let mut already_dead = false;
for path in &paths {
if killed.load(Acquire) || tx.send(path).is_err() { break; }
// Early abort in progress; mark as skipped instead of giving it
// to a worker.
if killed.load(Acquire) {
// Skip this path for sure.
let mut skipped = 1_u64;
undone.push(path);

// But also skip anything still in the queue.
if ! already_dead {
already_dead = true;
let before = undone.len();
undone.extend(rx.try_iter());
skipped += (undone.len() - before) as u64;
}

SKIPPED.fetch_add(skipped, Relaxed);
}
// Add the path to the queue; this shouldn't fail, but if it does
// add it to our list so we can let the user know at the end.
else if tx.send(path).is_err() {
SKIPPED.fetch_add(1, Relaxed);
undone.push(path);
}
}

// Disconnect and wait for the threads to finish!
Expand All @@ -246,6 +270,9 @@ fn _main() -> Result<(), FlacaError> {
summarize(&progress, total.get() as u64);
}

// Did anything get missed?
if ! undone.is_empty() { dump_undone(&undone); }

// Early abort?
if killed.load(Acquire) { Err(FlacaError::Killed) }
else { Ok(()) }
Expand Down Expand Up @@ -303,6 +330,32 @@ fn crunch_quiet(rx: &Receiver::<&Path>, kinds: ImageKind) {
while let Ok(p) = rx.recv() { let _res = crate::image::encode(p, kinds); }
}

#[cold]
/// # Dump Undone.
///
/// When aborting early, the unprocessed entries get dumped to a temporary
/// file, potentially.
fn dump_undone(undone: &[&Path]) {
// Merge the paths into a line-separated list, if we can.
let mut dump = String::new();
for p in undone {
let Some(p) = p.to_str() else { return; };
dump.push_str(p);
dump.push('\n');
}

// Save it if we can.
let path = std::env::temp_dir().join(format!("flaca-{}.txt", utc2k::unixtime()));
if write_atomic::write_file(&path, dump.as_bytes()).is_ok() {
Msg::notice(format!(
"{} missed during the run; their paths have
been exported to \x1b[95;1m{}\x1b[0m for reference.",
undone.len().nice_inflect("image was", "images were"),
path.to_string_lossy(),
)).eprint();
}
}

#[cold]
#[inline(never)]
/// # Print Help.
Expand Down
2 changes: 1 addition & 1 deletion flapfli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flapfli"
version = "3.1.7"
version = "3.1.8"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand Down
4 changes: 2 additions & 2 deletions release/man/flaca.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "FLACA" "1" "September 2024" "Flaca v3.1.7" "User Commands"
.TH "FLACA" "1" "September 2024" "Flaca v3.1.8" "User Commands"
.SH NAME
Flaca \- Manual page for flaca v3.1.7.
Flaca \- Manual page for flaca v3.1.8.
.SH DESCRIPTION
Brute\-force, lossless JPEG and PNG compression.
.SS USAGE:
Expand Down
Binary file added skel/assets/jpg/24.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e5f1c80

Please sign in to comment.