Image sets: a suffix that ends the number before is a repeat too
Test and deploy / test (push) Successful in 48s
Test and deploy / edge (push) Successful in 1m53s
Test and deploy / deploy (push) Successful in 1m24s

"051 - White leather kate054001_1_1.jpg": the index is inside 054001
(set 054, image 001) and _1_1 repeats it, but only a suffix equal to the
whole number before counted as a repeat, so the set kept 054001 and every
image was a release (Duke's threads: 2,791 releases of 3,251 files). A
suffix that the number before ends with is a repeat as well. Both
implementations; tests; fixtures identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-12 02:45:29 +02:00
1 parent 392ff09910
commit f094fb4593
3 files changed
+7 -2

No files matched your search

+3 -1
View File
@@ -430,7 +430,8 @@ pub fn image_set(stem: &str) -> String {
let Some(last) = before.iter().rposition(u8::is_ascii_digit) else { break };
let start = before[..=last].iter().rposition(|c| !c.is_ascii_digit()).map_or(0, |i| i + 1);
let previous = &before[start..=last];
let same = trim_zeros(n) == trim_zeros(previous);
// A repeat: the same number, or the end of the one before (054001 ends in 1).
let same = trim_zeros(n) == trim_zeros(previous) || previous.ends_with(n);
let year = n.len() == 4 && (n.starts_with(b"19") || n.starts_with(b"20"));
if same || year || n.len() >= 4 {
let cut = before.len();
@@ -1173,6 +1174,7 @@ mod image_set_tests {
("keira_s04_l keira_s04_0040_l", "keira_s04_l keira_s04_"),
("IMG_2676", "IMG_"),
("2877-041", "2877-"),
("051 - White leather kate054001_1_1", "051 - White leather kate"),
("JimAndJoey Kindly Husband-to-Be", ""),
] {
assert_eq!(image_set(stem), want, "{stem}");