From 1ca5259ca2881396165e8fdb73d9d59c3b2983f3 Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Thu, 28 Nov 2024 13:31:13 -0500 Subject: [PATCH] ref(dif): Make `try_assemble_dif` generic Now, `try_assemble_dif` can take arbitrary chunked objects (as long as we have a way to convert them into a `ChunkedDifRequest`). ref #2195 --- src/utils/dif_upload.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utils/dif_upload.rs b/src/utils/dif_upload.rs index ec0f5e1911..28ced9a358 100644 --- a/src/utils/dif_upload.rs +++ b/src/utils/dif_upload.rs @@ -1212,12 +1212,16 @@ fn create_il2cpp_mappings<'a>(difs: &[DifMatch<'a>]) -> Result> /// /// The returned value contains separate vectors for incomplete DIFs and /// missing chunks for convenience. -fn try_assemble_difs<'data, 'm>( - difs: &'m [Chunked>], +fn try_assemble<'m, T>( + objects: &'m [Chunked], options: &DifUpload, -) -> Result>> { +) -> Result> +where + T: AsRef<[u8]>, + Chunked: ToAssemble, +{ let api = Api::current(); - let request = difs + let request = objects .iter() .map(|d| d.to_assemble(options.pdbs_allowed)) .collect(); @@ -1231,7 +1235,7 @@ fn try_assemble_difs<'data, 'm>( // performed twice with the same data. While this is redundant, it is also // fast enough and keeping it here makes the `try_assemble_difs` interface // nicer. - let difs_by_checksum = difs + let difs_by_checksum = objects .iter() .map(|m| (m.checksum(), m)) .collect::>(); @@ -1550,7 +1554,7 @@ fn upload_difs_chunked( })?; // Upload missing chunks to the server and remember incomplete difs - let missing_info = try_assemble_difs(&chunked, options)?; + let missing_info = try_assemble(&chunked, options)?; upload_missing_chunks(&missing_info, chunk_options)?; // Only if DIFs were missing, poll until assembling is complete