h5rs: check URL opens the remote file once

open_arg_whole opened and parsed the remote file through open_arg, then
opened it again to download it, so every `h5rs check URL` probed the
server twice. It now opens the storage once and downloads through the
same block cache (whose first block the probe already filled).

Test: check --data of a file within one block costs exactly one request
(two before).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 18:36:35 -05:00
co-authored by Claude Opus 5.5
parent ef480746da
commit efb88f94e3
2 changed files with 18 additions and 4 deletions
+11
View File
@@ -158,3 +158,14 @@ fn credentials_in_urls_are_not_printed() {
"{out}"
);
}
/// `check URL` opens the file once: for a file within the first block,
/// one request in all (it probed the server twice before).
#[test]
fn check_url_probes_the_server_once() {
let tall = Path::new(env!("CARGO_MANIFEST_DIR")).join("../clawhdf5/tests/fixtures/tall.h5");
let server = server::Server::start(vec![("/t.h5".into(), std::fs::read(&tall).unwrap())]);
let (out, rc) = h5rs(&["check", "--data", &server.url("/t.h5")]);
assert_eq!(rc, 0, "{out}");
assert_eq!(server.requests(), 1, "{:?}", server.log());
}