From da094ea26178af9b95d0cab1d9c4a3759e6e1a4b Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 5 May 2025 16:53:46 -0400 Subject: [PATCH] Fix patch length parsing, add tests for it I don't know how this ever worked, but this was broken. I added checks for it in the patchlist parsing so it doesn't break again. --- src/patchlist.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/patchlist.rs b/src/patchlist.rs index e39fb49..bc7a689 100644 --- a/src/patchlist.rs +++ b/src/patchlist.rs @@ -54,7 +54,7 @@ impl PatchList { let mut patch_length = 0; if let Some(patch_length_index) = encoded.find("X-Patch-Length: ") { - let rest_of_string = &encoded[patch_length_index..]; + let rest_of_string = &encoded[patch_length_index + 16..]; if let Some(end_of_number_index) = rest_of_string.find("\r\n") { let patch_length_parse: Result = rest_of_string[0..end_of_number_index].parse(); @@ -193,6 +193,7 @@ mod tests { "http://patch-dl.ffxiv.com/boot/2b5cbc63/D2023.09.14.0000.0001.patch" ); assert_eq!(patch_list.patches[0].size_on_disk, 69674819); + assert_eq!(patch_list.patch_length, 22221335); } #[test] @@ -260,6 +261,7 @@ mod tests { "http://patch-dl.ffxiv.com/game/ex1/6b936f08/D2023.07.26.0000.0001.patch" ); assert_eq!(patch_list.patches[5].size_on_disk, 5854598228); + assert_eq!(patch_list.patch_length, 1664916486); } #[test]