Page the version name sweep with a resume cursor (#194)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9191257fbb
commit
008dd0e7f4
3 files changed
+139
-25
No files matched your search
@@ -253,6 +253,46 @@ async fn name_link_pairs_raw_and_jpeg_with_the_right_original() {
|
||||
);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn unresolvable_name_candidates_do_not_starve_later_ones() {
|
||||
let fx = fx();
|
||||
// Many matching rows with no original anywhere, then one linkable pair.
|
||||
for i in 0..120 {
|
||||
fx.put(
|
||||
&format!("album_a/aiedits/orphan{i}.jpg.edit.png"),
|
||||
format!("orphan {i}").as_bytes(),
|
||||
);
|
||||
}
|
||||
let original = fx.put("album_b/real.jpg", b"real original");
|
||||
let version = fx.put("album_b/aiedits/real.jpg.restored.png", b"real version");
|
||||
|
||||
let exif = fx.exif_arc();
|
||||
let mut cursor = 0;
|
||||
let mut total = 0;
|
||||
// One 50-row page per call: the old "ORDER BY id LIMIT n" would return
|
||||
// the same 50 orphans forever.
|
||||
for _ in 0..5 {
|
||||
total += sweep_name_links_from(
|
||||
&fx.library,
|
||||
&exif,
|
||||
&fx.state.version_dao,
|
||||
&mut cursor,
|
||||
50,
|
||||
1,
|
||||
);
|
||||
}
|
||||
assert_eq!(total, 1);
|
||||
let link = fx
|
||||
.state
|
||||
.version_dao
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_link(&version)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(link.original_hash, original);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn name_link_waits_for_the_original_to_be_hashed() {
|
||||
let fx = fx();
|
||||
|
||||
Reference in new issue
Block a user