Files
gromandClaude Opus 5 624ccec808 water: graft deepthought84's Improved Water onto this fork
The whole workspace compiles with his water in place of ours. Nothing is
verified beyond that yet -- no capture, no gates -- so this lands on
`water-port`, not on main.

Method: scripts/water-port-merge.sh stitches the common ancestor our squashed
history hides (both forks descend from samwhosung/benilla) and runs a real
three-way merge. 134 of his 168 files land clean; the 34 that conflict were
resolved by hand, 82 hunks, and the log is in docs/WATER_PORT.md.

What went, per grom's call (full swap, drop the extras): enhanced_water.wgsl,
liquid/{reflect,scene_depth,waves,lod}.rs, water_fx/bob.rs and the Water Quality
dropdown, with our LiquidExt bindings and the WaterDepth prepass they fed.

What was kept and re-applied onto his tree: the Ironforge magma palette
(MagmaTone, now multiplying the body before his stylised grade so a tinted pool's
crust and glow are its own colour) and our shader hooks -- fog, emissive,
monkey_frame, wind, wet, moonlight -- which his liquid.wgsl knew nothing about.

Four things needed real work rather than a side:
  * static_gx now keys its pipelines per VIEW, not per world camera, because his
    mirror and probe faces carry their own samples and format; our torch and
    light groups and the shadow-filter def ride along, and the depth-only twin
    his Hi-Z prepass needs is built beside each colour pipeline.
  * the booth layer ladder moved past the liquid render layers. His seam claims
    30 and 31; our pane block grew from UI_MODELS_LAYER with nothing stopping it
    reaching them, and the const assert fired exactly as the doc predicted.
  * two SystemParam tuples were already at the 16 ceiling (the minimap's blip
    inputs, the capture driver) and had to nest to take his.
  * sky.rs grew `dome_uniforms`, the one law his water march and the dome now
    share, without losing our Enhanced sky inputs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SgstFWtn1RxEJ5kVrpgYwn
2026-11-09 10:57:18 -07:00

638 lines
26 KiB
Rust

//! The vanilla patch chain: a priority-ordered set of MPQ archives, read through `benilla-mpq`. A
//! read resolves a name to the highest-priority archive holding it, so a patch wins; base archives
//! carry no `(listfile)`, so resolution is by name hash.
use std::collections::HashSet;
use std::path::Path;
use anyhow::{anyhow, bail, Context, Result};
use benilla_mpq::Archive;
use crate::VANILLA_BASE_ORDER;
/// One entry from a chain listing: an internal path and its uncompressed size.
pub struct ChainEntry {
pub name: String,
pub size: u64,
}
/// A priority-ordered patch chain of MPQ archives (`Send + Sync`; reads are `&self` and lock-free).
pub struct Chain {
/// Ascending priority: later archives win.
archives: Vec<Archive>,
}
/// `patch-?.MPQ` as the reference's `FindFirstFileW` glob matches it (template `0x82edbc`, wrapper
/// `0x42ad10`): `?` is exactly one character, any case, so `patch-10.MPQ` never mounts.
fn is_patch_glob_match(name: &str) -> bool {
let lower = name.to_ascii_lowercase();
let Some(mid) = lower
.strip_prefix("patch-")
.and_then(|rest| rest.strip_suffix(".mpq"))
else {
return false;
};
mid.chars().count() == 1
}
/// The reference's mount order over a `Data` listing, ascending priority (`0x403740`): the ten
/// [`VANILLA_BASE_ORDER`] archives, `patch.MPQ`, every `patch-?.MPQ` by case-folded name (the
/// reference sorts descending with `strnicmp` and walks backwards), then `speech2.MPQ`. Names
/// match case-insensitively and come back as found on disk.
fn mount_order(dir_names: &[String]) -> Vec<String> {
let find = |want: &str| {
dir_names
.iter()
.find(|n| n.eq_ignore_ascii_case(want))
.cloned()
};
let mut order: Vec<String> = VANILLA_BASE_ORDER.iter().filter_map(|b| find(b)).collect();
order.extend(find("patch.MPQ"));
let mut patches: Vec<String> = dir_names
.iter()
.filter(|n| is_patch_glob_match(n))
.cloned()
.collect();
patches.sort_by_key(|n| n.to_ascii_lowercase());
order.extend(patches);
order.extend(find("speech2.MPQ"));
order
}
/// The realm's interface manifest, the file whose copies say which archives hold a stale snapshot
/// of the realm's own data ([`demote_stale_snapshots`]).
const REALM_TOC: &str = "Interface\\FrameXML\\FrameXML.toc";
/// The rows of a `FrameXML.toc`, lowercased with separators normalised, for comparing two copies as
/// sets. Deliberately not the real toc parser (that lives in `benilla-ui`, which this crate does not
/// depend on): membership is all this needs, and a row is a line that is neither blank nor a
/// comment.
fn toc_row_keys(bytes: &[u8]) -> std::collections::HashSet<String> {
String::from_utf8_lossy(bytes)
.lines()
.map(|l| l.trim().trim_start_matches('\u{feff}'))
.filter(|l| !l.is_empty() && !l.starts_with('#'))
.map(|l| l.replace('/', "\\").to_ascii_lowercase())
.collect()
}
/// Deviation from the reference's mount law, and the only one here: an archive carrying a **strict
/// subset** of another archive's `FrameXML.toc` is a stale snapshot of the realm's own data, and is
/// mounted below every `patch-?.MPQ` instead of wherever its name sorted it.
///
/// `mount_order` is the reference's and stays so: `patch-?.MPQ` by case-folded name, last wins, so
/// a letter patch outranks a digit patch. A realm that ships its interface in `patch-5.mpq` is
/// therefore shadowed by any `patch-A.mpq` beside it — which on grom's install is exactly what
/// happened. `patch-A.mpq` holds an August snapshot of the realm's data: an older `FrameXML.toc`,
/// `GlobalStrings.lua`, the `OctoLocale` files, `AIO.lua`, the calendar, and a `Spell.dbc` 20 KB
/// behind. Every one of them won, so the client ran August's interface and August's spells with no
/// way to tell.
///
/// A toc that is a strict subset is what makes this decidable rather than a guess: it lists *fewer*
/// files than another copy and removes none, so it is an earlier edition of the same manifest, and
/// an archive holding an earlier edition of the realm's manifest holds earlier editions of the
/// realm's files. The demotion is to just below the patch set and no further, so anything only that
/// archive carries still resolves over `patch.MPQ` and the base archives — the point is to stop it
/// beating the realm's current patches, not to switch it off. An archive whose toc differs by
/// *removal* is a different manifest, not an older one, and is left exactly where its name puts it.
///
/// `WOW_CHAIN_DEMOTE=0` keeps the reference's order unchanged, for comparing against it.
fn demote_stale_snapshots(order: &mut Vec<String>, toc_of: impl Fn(&str) -> Option<Vec<u8>>) {
if std::env::var("WOW_CHAIN_DEMOTE").is_ok_and(|v| v == "0") {
return;
}
let tocs: Vec<(String, std::collections::HashSet<String>)> = order
.iter()
.filter(|n| is_patch_glob_match(n))
.filter_map(|n| toc_of(n).map(|b| (n.clone(), toc_row_keys(&b))))
.filter(|(_, rows)| !rows.is_empty())
.collect();
// The richest copy among the patches is the realm's current manifest; anything strictly inside
// it is an earlier edition of it.
let Some((_, richest)) = tocs.iter().max_by_key(|(_, rows)| rows.len()) else {
return;
};
let stale: Vec<String> = tocs
.iter()
.filter(|(_, rows)| rows.len() < richest.len() && rows.is_subset(richest))
.map(|(name, _)| name.clone())
.collect();
if stale.is_empty() {
return;
}
// Just below the patch set: above `patch.MPQ` and the base archives, below every `patch-?`.
let first_patch = order
.iter()
.position(|n| is_patch_glob_match(n))
.unwrap_or(order.len());
order.retain(|n| !stale.iter().any(|s| s == n));
for (i, name) in stale.into_iter().enumerate() {
order.insert(first_patch + i, name);
}
}
impl Chain {
/// Open a `Data` directory's archives in [`mount_order`], or a single `.MPQ` file.
///
/// Deviation: an archive that fails to open is an error, where the reference logs
/// `"Failed to open archive"` and goes on, because a skipped corrupt archive surfaces only as
/// missing files far downstream.
pub fn open(path: &Path) -> Result<Self> {
let mut archives = Vec::new();
if path.is_dir() {
let mut names: Vec<String> = std::fs::read_dir(path)
.with_context(|| format!("listing {}", path.display()))?
.filter_map(|entry| {
let entry = entry.ok()?;
// `path().is_file()` follows symlinks (`read_dir`'s file_type doesn't).
entry.path().is_file().then(|| entry.file_name())
})
.filter_map(|name| name.into_string().ok())
.collect();
// read_dir order is arbitrary; sort so case-variant ties resolve deterministically.
names.sort();
let mut order = mount_order(&names);
if order.is_empty() {
bail!("no known vanilla MPQs found in {}", path.display());
}
// Opened before the order is final, because the order depends on what they hold:
// `demote_stale_snapshots` reads one file out of each patch archive to decide.
let mut opened: Vec<(String, Option<Archive>)> = Vec::with_capacity(order.len());
for name in &order {
let mpq = path.join(name);
let archive =
Archive::open(&mpq).with_context(|| format!("opening {}", mpq.display()))?;
opened.push((name.clone(), Some(archive)));
}
demote_stale_snapshots(&mut order, |want| {
opened
.iter()
.find(|(name, _)| name == want)
.and_then(|(_, a)| a.as_ref())
.filter(|a| a.contains(REALM_TOC) && !a.is_delete_marker(REALM_TOC))
.and_then(|a| a.read_file(REALM_TOC).ok())
});
for name in &order {
let slot = opened
.iter_mut()
.find(|(n, a)| n == name && a.is_some())
.expect("every ordered name was opened above");
archives.push(slot.1.take().expect("checked by the find"));
}
} else {
archives.push(
Archive::open(path).with_context(|| format!("opening MPQ {}", path.display()))?,
);
}
Ok(Self { archives })
}
/// A hash of the mounted archives' paths, sizes and modification times: what a cache derived
/// from this chain's contents is keyed on, so a patched install invalidates it.
pub fn fingerprint(&self) -> u64 {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
for a in &self.archives {
a.path().hash(&mut h);
if let Ok(meta) = std::fs::metadata(a.path()) {
meta.len().hash(&mut h);
meta.modified().ok().hash(&mut h);
}
}
h.finish()
}
/// The highest-priority archive with an entry for `name`, a delete marker included, as a
/// tombstone shadows every lower copy: check [`Archive::is_delete_marker`] for a readable file.
fn resolve(&self, name: &str) -> Option<&Archive> {
self.archives.iter().rev().find(|a| a.contains(name))
}
/// Whether `name` (`/` or `\`, any case) is a readable file, not a delete marker.
pub fn contains(&self, name: &str) -> bool {
self.resolve(name)
.is_some_and(|a| !a.is_delete_marker(name))
}
/// The path of the archive `name` resolves to, for debugging and extraction.
pub fn find_file_archive(&self, name: &str) -> Option<&Path> {
self.resolve(name).map(|a| a.path())
}
/// Read a file by internal path (`/` or `\`) from its winning archive.
pub fn read(&self, name: &str) -> Result<Vec<u8>> {
let archive = self
.resolve(name)
.ok_or_else(|| anyhow!("file not in patch chain: {name}"))?;
// A tombstone deletes the path from the composite: not found, never a stale lower copy.
if archive.is_delete_marker(name) {
bail!(
"file deleted from patch chain: {name} (tombstoned by {})",
archive.path().display()
);
}
archive
.read_file(name)
.with_context(|| format!("reading {name} from {}", archive.path().display()))
}
/// `&mut` alias of [`Chain::read`] for call sites that thread a `&mut Chain`.
pub fn read_file(&mut self, name: &str) -> Result<Vec<u8>> {
self.read(name)
}
/// Every archive's copy of `name` with the archive it came from, **ascending priority**, so the
/// last is the one [`Self::read`] answers with and the others are shadowed.
///
/// A read never wants this: one name is one file, and the winner is the answer. A *diagnosis*
/// does, because a shadowed copy is invisible by construction and some of them matter — an
/// archive mounting above the realm's own can carry a stale `FrameXML.toc`, and then the
/// interface silently loads an older list of files than the realm ships, which is a missing
/// feature with nothing anywhere to say why. Stops at the first tombstone from the top, as a
/// read does: a copy under a delete marker is not shadowed, it is deleted.
pub fn read_all(&self, name: &str) -> Vec<(&Path, Vec<u8>)> {
let mut out = Vec::new();
for archive in self.archives.iter().rev() {
if !archive.contains(name) {
continue;
}
if archive.is_delete_marker(name) {
break;
}
if let Ok(bytes) = archive.read_file(name) {
out.push((archive.path(), bytes));
}
}
out.reverse();
out
}
/// Every archive holding `name` with that copy's uncompressed size, **ascending priority**, as
/// [`Self::read_all`] orders its bytes — but from the hash and block tables alone, so it costs
/// a lookup per archive and decompresses nothing.
///
/// For asking *which* copies of a file exist and whether they differ, over a list of names,
/// where reading each one would mean megabytes to answer a question about bytes nobody wants.
/// Equal sizes are not proof of equal content; differing sizes are proof of differing content,
/// which is the direction a staleness check needs.
pub fn copies(&self, name: &str) -> Vec<(&Path, u32)> {
let mut out = Vec::new();
for archive in self.archives.iter().rev() {
if !archive.contains(name) {
continue;
}
if archive.is_delete_marker(name) {
break;
}
if let Some(size) = archive.file_size(name) {
out.push((archive.path(), size));
}
}
out.reverse();
out
}
/// The chain's named files with sizes, for development and extraction; a file in no listfile
/// (most of `texture.MPQ`) is readable by name but not listed. Unions every archive's
/// `(listfile)`, as each names only its own files; sizes come from the winning archive.
pub fn list(&self) -> Result<Vec<ChainEntry>> {
self.list_filtered(None)
}
/// [`Self::list`] restricted to the names under `prefix`, compared the way MPQ hashing
/// compares names: any case, `/` and `\` alike.
///
/// Worth having because the *filter* is what the walk costs. Per name a full list allocates a
/// normalized dedup key, hashes it, resolves the winning archive and asks it for a size; the
/// prefix test is a byte compare that runs before all of it. On this install's chain — 102,144
/// listfile entries — a full list is 471 ms where `Interface\Icons\` out of it is 51 ms, the
/// same 3,205 entries either way ([`crate::macro_icons`]'s catalog is the one caller that
/// wants a directory rather than the lot; the rest is `benilla-extract`, which wants the lot).
pub fn list_under(&self, prefix: &str) -> Result<Vec<ChainEntry>> {
let key: Vec<u8> = prefix
.bytes()
.map(|b| {
if b == b'/' {
b'\\'
} else {
b.to_ascii_lowercase()
}
})
.collect();
self.list_filtered(Some(&key))
}
/// The shared body: `prefix` is already lowercased with `\` separators.
fn list_filtered(&self, prefix: Option<&[u8]>) -> Result<Vec<ChainEntry>> {
let under = |name: &str| match prefix {
None => true,
Some(p) => {
let n = name.as_bytes();
n.len() >= p.len()
&& n[..p.len()].iter().zip(p).all(|(&a, &b)| {
(if a == b'/' {
b'\\'
} else {
a.to_ascii_lowercase()
}) == b
})
}
};
let mut seen = HashSet::new();
let mut out = Vec::new();
for archive in &self.archives {
let Ok(listfile) = archive.read_file("(listfile)") else {
continue;
};
for raw in String::from_utf8_lossy(&listfile).split([';', '\r', '\n']) {
let name = raw.trim();
if name.is_empty() || !under(name) {
continue;
}
// Dedupe the way MPQ hashing compares names: any case, `/` and `\` alike.
if !seen.insert(name.replace('/', "\\").to_ascii_lowercase()) {
continue;
}
if let Some(a) = self.resolve(name) {
// A tombstoned path is not a file in the composite.
if a.is_delete_marker(name) {
continue;
}
out.push(ChainEntry {
name: name.to_string(),
size: a.file_size(name).unwrap_or(0) as u64,
});
}
}
}
Ok(out)
}
}
#[cfg(test)]
mod tests {
use super::*;
fn owned(names: &[&str]) -> Vec<String> {
names.iter().map(|n| n.to_string()).collect()
}
#[test]
fn patch_glob_matches_exactly_one_character_case_insensitively() {
assert!(is_patch_glob_match("patch-2.MPQ"));
assert!(is_patch_glob_match("patch-3.MPQ"));
assert!(is_patch_glob_match("PATCH-A.mpq"));
assert!(!is_patch_glob_match("patch-.MPQ"));
assert!(!is_patch_glob_match("patch-10.MPQ"));
assert!(!is_patch_glob_match("patch-33.MPQ"));
assert!(!is_patch_glob_match("patch.MPQ"));
assert!(!is_patch_glob_match("patch-2.MPQ.bak"));
assert!(!is_patch_glob_match("mypatch-2.MPQ"));
}
/// The demotion: an archive whose `FrameXML.toc` is a strict subset of another's is an earlier
/// edition of the realm's manifest, so it drops below the whole patch set — above `patch.MPQ`
/// and the base archives, so anything only it carries still resolves.
#[test]
fn a_stale_snapshot_drops_below_the_patch_set() {
let toc = |rows: &[&str]| rows.join("\n").into_bytes();
let mut order = owned(&[
"dbc.MPQ",
"patch.MPQ",
"patch-1.mpq",
"patch-5.mpq",
"patch-A.mpq",
"Patch-B.mpq",
"speech2.MPQ",
]);
demote_stale_snapshots(&mut order, |name| match name {
// The realm's current manifest, and an August copy of it with three rows missing.
"patch-5.mpq" => Some(toc(&["A.lua", "B.lua", "C.lua", "D.lua"])),
"patch-A.mpq" => Some(toc(&["A.lua"])),
_ => None,
});
assert_eq!(
order,
owned(&[
"dbc.MPQ",
"patch.MPQ",
"patch-A.mpq",
"patch-1.mpq",
"patch-5.mpq",
"Patch-B.mpq",
"speech2.MPQ",
]),
"below every patch-?, above patch.MPQ and the base archives"
);
}
/// A toc that *differs* rather than lags is a different manifest, not an earlier edition of
/// one, and nothing here can arbitrate between them — so the reference's order stands.
#[test]
fn a_toc_that_drops_a_row_is_left_where_its_name_puts_it() {
let toc = |rows: &[&str]| rows.join("\n").into_bytes();
let before = owned(&["patch.MPQ", "patch-5.mpq", "patch-A.mpq"]);
let mut order = before.clone();
demote_stale_snapshots(&mut order, |name| match name {
"patch-5.mpq" => Some(toc(&["A.lua", "B.lua", "C.lua"])),
// Fewer rows, but one the richest copy does not have: not a subset.
"patch-A.mpq" => Some(toc(&["A.lua", "Gone.lua"])),
_ => None,
});
assert_eq!(order, before);
// And the richest copy is never demoted against itself.
let mut order = before.clone();
demote_stale_snapshots(&mut order, |name| match name {
"patch-5.mpq" => Some(toc(&["A.lua"])),
"patch-A.mpq" => Some(toc(&["A.lua"])),
_ => None,
});
assert_eq!(order, before, "equal manifests are not stale ones");
}
/// A letter patch mounts **above** a digit patch, because the reference sorts the glob's hits
/// by case-folded name and walks them so the last wins. Pinned on its own because it is not a
/// detail: a realm that ships its interface in `patch-5.mpq` has it shadowed by any
/// `patch-A.mpq` on the same disk, which on grom's install silently cost six FrameXML rows and
/// the `/xpboost` command (`ui_script::reference_ui::realm_toc_rows`).
#[test]
fn a_letter_patch_mounts_above_a_digit_patch() {
let dir = owned(&["patch-A.mpq", "patch-5.mpq", "patch-1.mpq", "Patch-Q.mpq"]);
assert_eq!(
mount_order(&dir),
owned(&["patch-1.mpq", "patch-5.mpq", "patch-A.mpq", "Patch-Q.mpq"]),
"ascending priority: the later entry's copy of a file wins"
);
}
/// The invariant the demotion exists for, on whatever chain this machine has: the archive that
/// wins the realm's `FrameXML.toc` is the one holding the richest copy of it. Vacuous on an
/// install with a single copy, and the whole point on one with a stale snapshot mounted high.
/// Prints where the realm's most update-sensitive files resolve, so `--nocapture` after a
/// client update shows whether its archives are the ones being read.
#[test]
fn the_realms_current_data_wins_over_a_stale_snapshot() {
let Some(data) = crate::wow_data() else {
eprintln!("skipped: no client data");
return;
};
let chain = Chain::open(&data).expect("open the patch chain");
let copies = chain.read_all(REALM_TOC);
if copies.is_empty() {
eprintln!("skipped: this chain carries no FrameXML.toc");
return;
}
let rows = |bytes: &[u8]| toc_row_keys(bytes).len();
let (winner_at, winner_bytes) = copies.last().expect("a copy");
let richest = copies
.iter()
.max_by_key(|(_, bytes)| rows(bytes))
.expect("a copy");
for name in [
REALM_TOC,
"Interface\\FrameXML\\GlobalStrings.lua",
"DBFilesClient\\Spell.dbc",
] {
let at = chain.find_file_archive(name);
eprintln!(
"{name} resolves to {}",
at.map_or("nowhere".into(), |p| p.display().to_string())
);
}
assert_eq!(
rows(winner_bytes),
rows(&richest.1),
"the realm's toc is won by {} with {} rows while {} holds {} \u{2014} a stale snapshot \
is still outranking the realm's own data",
winner_at.display(),
rows(winner_bytes),
richest.0.display(),
rows(&richest.1)
);
}
/// [`Chain::read_all`]'s contract, on a real chain: the copies come back in ascending priority
/// and the last of them is the one [`Chain::read`] answers with.
#[test]
fn read_all_ends_with_the_copy_a_read_answers_with() {
let Some(data) = crate::wow_data() else {
eprintln!("skipped: no client data");
return;
};
let chain = Chain::open(&data).expect("open the patch chain");
// A name every vanilla chain carries in more than one archive.
let name = "Interface\\FrameXML\\FrameXML.toc";
let copies = chain.read_all(name);
assert!(
copies.len() > 1,
"this chain holds {} copy of {name}, so the ordering is untested here",
copies.len()
);
let (at, bytes) = copies.last().expect("a copy");
assert_eq!(
*bytes,
chain.read(name).expect("the winning copy"),
"the last copy must be the one a read returns; it came from {}",
at.display()
);
assert_eq!(
Some(*at),
chain.find_file_archive(name),
"and the archive it names must be the one the resolver picks"
);
}
#[test]
fn mount_order_is_the_carved_law() {
// base.MPQ is telemetry-only in the reference and never mounts.
let dir = owned(&[
"patch-2.MPQ",
"backup.MPQ",
"model.MPQ",
"base.MPQ",
"dbc.MPQ",
"patch.MPQ",
"eula.html",
"patch-3.MPQ",
"speech2.MPQ",
"texture.MPQ",
]);
assert_eq!(
mount_order(&dir),
owned(&[
"dbc.MPQ",
"texture.MPQ",
"model.MPQ",
"patch.MPQ",
"patch-2.MPQ",
"patch-3.MPQ",
"speech2.MPQ",
])
);
}
#[test]
fn patch_sort_is_ascending_and_case_folded() {
let dir = owned(&["patch-B.MPQ", "patch-3.MPQ", "patch-a.MPQ", "patch-2.MPQ"]);
assert_eq!(
mount_order(&dir),
owned(&["patch-2.MPQ", "patch-3.MPQ", "patch-a.MPQ", "patch-B.MPQ"])
);
}
#[test]
fn base_archives_are_found_case_insensitively() {
let dir = owned(&["DBC.mpq", "Model.MPQ", "PATCH.mpq"]);
assert_eq!(
mount_order(&dir),
owned(&["DBC.mpq", "Model.MPQ", "PATCH.mpq"])
);
}
/// `list_under` answers exactly what filtering a full `list` answers, and far faster: the
/// numbers this prints are the ones quoted in [`Chain::list_under`]'s doc.
#[test]
fn a_prefix_list_is_the_full_list_filtered_and_pays_for_the_prefix_only() {
let data = crate::wow_data_or_skip!();
let chain = crate::open_chain(&data).expect("open chain");
const DIR: &str = "Interface\\Icons\\";
let t0 = std::time::Instant::now();
let all = chain.list().expect("list");
let full_ms = t0.elapsed().as_secs_f32() * 1000.0;
let t1 = std::time::Instant::now();
let under = chain.list_under(DIR).expect("list_under");
let under_ms = t1.elapsed().as_secs_f32() * 1000.0;
let norm = |n: &str| n.replace('/', "\\").to_ascii_lowercase();
let mut want: Vec<String> = all
.iter()
.map(|e| norm(&e.name))
.filter(|n| n.starts_with(&norm(DIR)))
.collect();
let mut got: Vec<String> = under.iter().map(|e| norm(&e.name)).collect();
want.sort();
got.sort();
eprintln!(
"chain listfile union {} entries in {full_ms:.0} ms; {DIR} is {} entries in \
{under_ms:.0} ms",
all.len(),
under.len()
);
assert_eq!(got, want, "the filtered list and the full list must agree");
assert!(
!got.is_empty(),
"this install has icons — otherwise nothing is proven"
);
// Sizes come from the same winning archive either way.
for e in &under {
let full = all
.iter()
.find(|f| norm(&f.name) == norm(&e.name))
.expect("in the full list too");
assert_eq!(e.size, full.size, "{}", e.name);
}
}
}