Skip to content

Commit

Permalink
release: 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Oct 5, 2023
2 parents b945140 + 576b77f commit 69fa288
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 237 deletions.
22 changes: 11 additions & 11 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
# Project Dependencies
Package: riprip
Version: 0.1.7
Generated: 2023-09-30 05:52:37 UTC
Version: 0.2.0
Generated: 2023-10-05 22:27:19 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.3 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
| [argyle](https://github.com/Blobfolio/argyle) | 0.6.8 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [base64](https://github.com/marshallpierce/rust-base64) | 0.21.4 | [Alice Maz](mailto:[email protected]) and [Marshall Pierce](mailto:[email protected]) | Apache-2.0 or MIT |
| [block-buffer](https://github.com/RustCrypto/utils) | 0.10.4 | RustCrypto Developers | Apache-2.0 or MIT |
| [bytecount](https://github.com/llogiq/bytecount) | 0.6.3 | [Andre Bogus](mailto:[email protected]) and [Joshua Landau](mailto:[email protected]) | Apache-2.0 or MIT |
| [cdtoc](https://github.com/Blobfolio/cdtoc) | 0.2.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [bytecount](https://github.com/llogiq/bytecount) | 0.6.4 | [Andre Bogus](mailto:[email protected]) and [Joshua Landau](mailto:[email protected]) | Apache-2.0 or MIT |
| [cdtoc](https://github.com/Blobfolio/cdtoc) | 0.3.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [crc32fast](https://github.com/srijs/rust-crc32fast) | 1.3.2 | [Sam Rijs](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [crypto-common](https://github.com/RustCrypto/traits) | 0.1.6 | RustCrypto Developers | Apache-2.0 or MIT |
| [ctrlc](https://github.com/Detegr/rust-ctrlc.git) | 3.4.1 | [Antti Keränen](mailto:[email protected]) | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.5.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.5.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [digest](https://github.com/RustCrypto/traits) | 0.10.7 | RustCrypto Developers | Apache-2.0 or MIT |
| [faster-hex](https://github.com/NervosFoundation/faster-hex) | 0.8.1 | [zhangsoledad](mailto:[email protected]) | MIT |
| [fastrand](https://github.com/smol-rs/fastrand) | 2.0.1 | [Stjepan Glavina](mailto:[email protected]) | Apache-2.0 or MIT |
| [form_urlencoded](https://github.com/servo/rust-url) | 1.2.0 | The rust-url developers | Apache-2.0 or MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.11.5 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.11.6 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [generic-array](https://github.com/fizyk20/generic-array.git) | 0.14.7 | [Bartłomiej Kamiński](mailto:[email protected]) and [Aaron Trent](mailto:[email protected]) | MIT |
| [idna](https://github.com/servo/rust-url/) | 0.4.0 | The rust-url developers | Apache-2.0 or MIT |
| [itoa](https://github.com/dtolnay/itoa) | 1.0.9 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [libcdio-sys](https://github.com/gmes78/libcdio-sys) | 0.5.0 | [Joaquim Monteiro](mailto:[email protected]) | GPL-3.0+ |
| [log](https://github.com/rust-lang/log) | 0.4.20 | The Rust Project Developers | Apache-2.0 or MIT |
| [num-traits](https://github.com/rust-num/num-traits) | 0.2.16 | The Rust Project Developers | Apache-2.0 or MIT |
| [once_cell](https://github.com/matklad/once_cell) | 1.18.0 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
| [oxford_join](https://github.com/Blobfolio/oxford_join) | 0.2.8 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [oxford_join](https://github.com/Blobfolio/oxford_join) | 0.2.9 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [percent-encoding](https://github.com/servo/rust-url/) | 2.3.0 | The rust-url developers | Apache-2.0 or MIT |
| [riprip_core](https://github.com/Blobfolio/riprip) | 0.1.7 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [riprip_core](https://github.com/Blobfolio/riprip) | 0.2.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [sha1](https://github.com/RustCrypto/hashes) | 0.10.6 | RustCrypto Developers | Apache-2.0 or MIT |
| [tempfile](https://github.com/Stebalien/tempfile) | 3.8.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 |
| [term_size](https://github.com/kbknapp/term_size-rs.git) | 0.3.2 | [Kevin K.](mailto:[email protected]) and [Benjamin Sago](mailto:[email protected]) | Apache-2.0 or MIT |
| [tinyvec](https://github.com/Lokathor/tinyvec) | 1.6.0 | [Lokathor](mailto:[email protected]) | Apache-2.0, MIT, or Zlib |
| [tinyvec_macros](https://github.com/Soveu/tinyvec_macros) | 0.1.1 | [Soveu](mailto:[email protected]) | Apache-2.0, MIT, or Zlib |
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.1.8 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.2.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [typenum](https://github.com/paholg/typenum) | 1.17.0 | [Paho Lurie-Gregg](mailto:[email protected]) and [Andre Bogus](mailto:[email protected]) | Apache-2.0 or MIT |
| [unicode-bidi](https://github.com/servo/unicode-bidi) | 0.3.13 | The Servo Project Developers | Apache-2.0 or MIT |
| [unicode-normalization](https://github.com/unicode-rs/unicode-normalization) | 0.1.22 | [kwantam](mailto:[email protected]) and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
| [unicode-width](https://github.com/unicode-rs/unicode-width) | 0.1.11 | [kwantam](mailto:[email protected]) and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
| [ureq](https://github.com/algesten/ureq) | 2.7.1 | [Martin Algesten](mailto:[email protected]) and [Jacob Hoffman-Andrews](mailto:[email protected]) | Apache-2.0 or MIT |
| [ureq](https://github.com/algesten/ureq) | 2.8.0 | [Martin Algesten](mailto:[email protected]) and [Jacob Hoffman-Andrews](mailto:[email protected]) | Apache-2.0 or MIT |
| [url](https://github.com/servo/rust-url) | 2.4.1 | The rust-url developers | Apache-2.0 or MIT |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.6.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.7.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
4 changes: 2 additions & 2 deletions release/man/riprip.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "RIP RIP HOORAY!" "1" "September 2023" "Rip Rip Hooray! v0.1.7" "User Commands"
.TH "RIP RIP HOORAY!" "1" "October 2023" "Rip Rip Hooray! v0.2.0" "User Commands"
.SH NAME
Rip Rip Hooray! \- Manual page for riprip v0.1.7.
Rip Rip Hooray! \- Manual page for riprip v0.2.0.
.SH DESCRIPTION
A specialized audio CD\-ripper optimized for incremental data recovery.
.SS USAGE:
Expand Down
8 changes: 4 additions & 4 deletions riprip/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "riprip"
version = "0.1.7"
version = "0.2.0"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
rust-version = "1.70"
rust-version = "1.73"
description = "A specialized audio CD-ripper optimized for incremental data recovery."
repository = "https://github.com/Blobfolio/riprip"
readme = "README.md"
Expand Down Expand Up @@ -127,8 +127,8 @@ argyle = "0.6.*"
ctrlc = "3.4.*"
dactyl = "0.5"
oxford_join = "0.2.*"
trimothy = "0.1.*"
utc2k = "0.6.*"
trimothy = "0.2.*"
utc2k = "0.7.*"

[dependencies.fyi_msg]
version = "0.11.*"
Expand Down
15 changes: 10 additions & 5 deletions riprip_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[package]
name = "riprip_core"
version = "0.1.7"
version = "0.2.0"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
rust-version = "1.70"
rust-version = "1.73"
description = "The library for Rip Rip Hooray."
repository = "https://github.com/Blobfolio/riprip"
readme = "README.md"
publish = false

[dependencies]
cdtoc = "0.2.*"
cdtoc = "0.3.*"
crc32fast = "1.3.2"
dactyl = "0.5.*"
tempfile = "3.8.0"
trimothy = "0.1.*"
utc2k = "0.6.*"
trimothy = "0.2.*"
utc2k = "0.7.*"

[dependencies.argyle]
version = "0.6.*"
Expand All @@ -37,6 +37,11 @@ default-features = false
# Neither AccurateRip nor CTDB use SSL for whatever
# reason so we don't need any ureq features at all!

[build-dependencies.cdtoc]
version = "0.3.*"
default-features = false
features = [ "accuraterip" ]

[build-dependencies.ureq]
version = "2.7.0"
default-features = false
Expand Down
147 changes: 31 additions & 116 deletions riprip_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This downloads and parses the AccurateRip drive offset list into a constant
array that can be easily searched at runtime.
*/

use cdtoc::AccurateRip;
use std::{
collections::BTreeMap,
fs::{
Expand All @@ -28,21 +29,6 @@ use std::{
/// This mirrors the DriveVendorModel type in the living program.
type VendorModel = [u8; 24];

/// # The remote URL of the data.
const DATA_URL: &str = "http://www.accuraterip.com/accuraterip/DriveOffsets.bin";

/// # Min Offset.
const MIN_OFFSET: i16 = -5880;

/// # Max Offset.
const MAX_OFFSET: i16 = 5880;

/// # Max Vendor Length.
const MAX_VENDOR_LEN: usize = 8;

/// # Max Model Length.
const MAX_MODEL_LEN: usize = 16;



/// # Main.
Expand All @@ -54,10 +40,14 @@ fn main() {
let offsets = parse_offsets(&raw);
let caches = parse_caches(&offsets);

// Save the offsets.
let dst = out_path("drives.rs");
// Announce the totals for reference.
let len = offsets.len().to_string().len();
println!("cargo:warning=Read Offsets: {}", offsets.len());
println!("cargo:warning=Cache Sizes: {:>len$}", caches.len());

// Save it!
let data = [nice_caches(caches), nice_offsets(offsets)].concat();
File::create(dst)
File::create(out_path("drives.rs"))
.and_then(|mut f| f.write_all(data.as_bytes()).and_then(|_| f.flush()))
.expect("Unable to save drive data.");
}
Expand All @@ -74,7 +64,7 @@ fn fetch_offsets() -> Vec<u8> {
if let Some(x) = try_cache(&cache) { return x; }

// Download it fresh.
let res = ureq::get(DATA_URL)
let res = ureq::get(AccurateRip::DRIVE_OFFSET_URL)
.set("user-agent", "Mozilla/5.0")
.call()
.expect("Unable to download AccurateRip drive offsets.");
Expand Down Expand Up @@ -109,8 +99,6 @@ fn nice_caches(parsed: BTreeMap<VendorModel, u16>) -> String {
))
.collect::<Vec<String>>();

println!("cargo:warning=Found {} drive caches in the database.", nice.len());

format!(
r#"
/// # Drive Cache Sizes.
Expand All @@ -134,22 +122,12 @@ fn nice_offsets(parsed: BTreeMap<VendorModel, i16>) -> String {
use std::fmt::Write;

// Reformat the data into "code" for the array we're about to generate.
let mut min = i16::MAX;
let mut max = i16::MIN;
let nice = parsed.into_iter()
.map(|(vendormodel, offset)| {
if offset < min { min = offset; }
if offset > max { max = offset; }
.map(|(vendormodel, offset)|
format!("(DriveVendorModel({vendormodel:?}), ReadOffset({offset})),")
})
)
.collect::<Vec<String>>();

// Announce the count so the builder can see what's going on under the
// hood. There should be a few thousand.
println!("cargo:warning=Found {} drive offsets in the database.", nice.len());
println!("cargo:warning=Min offset: {min}.");
println!("cargo:warning=Max offset: {max}.");

// Start the array.
let mut out = format!(
r#"
Expand Down Expand Up @@ -236,94 +214,31 @@ fn parse_cache_line(line: &str) -> Option<(VendorModel, u16)> {
///
/// We only care about the first two parts.
fn parse_offsets(raw: &[u8]) -> BTreeMap<VendorModel, i16> {
let mut parsed: BTreeMap<VendorModel, i16> = BTreeMap::new();

// Run through each entry.
for chunk in raw.chunks_exact(69) {
// Parsing numbers is so nice!
let offset = i16::from_le_bytes([chunk[0], chunk[1]]);

// Ignore entries with an offset of zero (our default) as well as
// anything beyond our supported range, although at present no entries
// come close to that.
if offset == 0 || ! (MIN_OFFSET..=MAX_OFFSET).contains(&offset) { continue; }

// The drive ID may be null-padded on the end. Let's trim those away.
let mut drive_id = &chunk[2..34];
while let [ rest @ .., 0 ] = drive_id { drive_id = rest; }

// Make sure it is valid UTF-8.
let Ok(drive_id) = std::str::from_utf8(drive_id) else { continue; };

// Both the vendor and model have fixed lengths on the hardware side;
// we can store them together to make the search more efficient. This
// structure matches `DriveVendorModel` in our source.
let mut vendormodel = VendorModel::default();

// AccurateRip doesn't take advantage of the inherent field sizes. It
// concatenates the two with " - " instead, or "- " in cases where the
// vendor part is absent.

// Let's check for no-vendor first.
if let Some(mut model) = drive_id.strip_prefix("- ") {
model = model.trim();

// Model is required and must fit within its maximum length.
if (1..=MAX_MODEL_LEN).contains(&model.len()) {
// Pretty sure these have to be ASCII.
if ! model.is_ascii() {
println!("cargo:warning=Non-ASCII model {model}.");
continue;
}

for (b, v) in vendormodel.iter_mut().skip(MAX_VENDOR_LEN).zip(model.bytes()) {
*b = v.to_ascii_uppercase();
}
if let Some(offset1) = parsed.insert(vendormodel, offset) {
if offset1 != offset {
println!("cargo:warning=Multiple offsets: [no vendor] / {model} ({offset1}, {offset}).");
}
}
}
// CDTOC does most of the work for us, but we can ignore 0-offset entries,
// and will uppercase the vendor/model pairs for case-insensitive
// searching.
let parsed: BTreeMap<VendorModel, i16> = AccurateRip::parse_drive_offsets(raw)
.expect("Unable to parse drive offsets.")
.into_iter()
.filter_map(|((v, m), o)|
if o == 0 { None }
else {
println!("cargo:warning=Invalid: [no vendor] / {model}.");
}
}
// Otherwise it will look like "VENDOR - MODEL".
else {
let mut split = drive_id.splitn(2, " - ");
let Some(mut vendor) = split.next() else { continue; };
let Some(mut model) = split.next() else { continue; };
vendor = vendor.trim();
model = model.trim();

// Both are required and must fit within their maximum lengths.
if (1..=MAX_VENDOR_LEN).contains(&vendor.len()) && (1..=MAX_MODEL_LEN).contains(&model.len()) {
// Pretty sure these have to be ASCII.
if ! vendor.is_ascii() || ! model.is_ascii() {
println!("cargo:warning=Non-ASCII vendor/model {vendor} / {model}.");
continue;
}

for (b, v) in vendormodel.iter_mut().zip(vendor.bytes()) {
*b = v.to_ascii_uppercase();
// Reformat the vendor/model pairs into our array.
let mut vm = VendorModel::default();
if ! v.is_empty() {
for (old, new) in vm.iter_mut().zip(v.bytes()) {
*old = new.to_ascii_uppercase();
}
}
for (b, v) in vendormodel.iter_mut().skip(MAX_VENDOR_LEN).zip(model.bytes()) {
*b = v.to_ascii_uppercase();
for (old, new) in vm.iter_mut().skip(8).zip(m.bytes()) {
*old = new.to_ascii_uppercase();
}

// Add it!
if let Some(offset1) = parsed.insert(vendormodel, offset) {
if offset1 != offset {
println!("cargo:warning=Multiple offsets: {vendor} / {model} ({offset1}, {offset}).");
}
}
}
else {
println!("cargo:warning=Invalid: {vendor} / {model}.");
// And return!
Some((vm, o))
}
}
}
)
.collect();

// Make sure we parsed something.
if parsed.is_empty() { panic!("No drive offsets could be parsed."); }
Expand Down
2 changes: 1 addition & 1 deletion riprip_core/src/cdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl LibcdioInstance {
while from < to && 0 < *todo {
if killed.killed() { break; }
if
! SHITLIST.with(|q| q.borrow().contains(&from)) &&
! SHITLIST.with_borrow(|q| q.contains(&from)) &&
self.read_cd(buf, from, false, 0, CD_DATA_SIZE).is_ok()
{ *todo -= 1; }
from += 1;
Expand Down
2 changes: 1 addition & 1 deletion riprip_core/src/disc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ impl Disc {
}

// An extra line break for separation.
let _res = writeln!(&mut handle).and_then(|_| handle.flush());
let _res = writeln!(&mut handle).and_then(|()| handle.flush());
}

Ok(())
Expand Down
Loading

0 comments on commit 69fa288

Please sign in to comment.