Skip to content

Commit

Permalink
ref(dif): Make try_assemble_dif generic
Browse files Browse the repository at this point in the history
Now, `try_assemble_dif` can take arbitrary chunked objects (as long as we have a way to convert them into a `ChunkedDifRequest`).

ref #2195
  • Loading branch information
szokeasaurusrex committed Nov 28, 2024
1 parent 93897c3 commit 748d28d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/utils/dif_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,12 +1212,16 @@ fn create_il2cpp_mappings<'a>(difs: &[DifMatch<'a>]) -> Result<Vec<DifMatch<'a>>
///
/// The returned value contains separate vectors for incomplete DIFs and
/// missing chunks for convenience.
fn try_assemble_difs<'data, 'm>(
difs: &'m [ChunkedObject<DifMatch<'data>>],
fn try_assemble_objects<'m, T>(
objects: &'m [ChunkedObject<T>],
options: &DifUpload,
) -> Result<MissingObjectsInfo<'m, DifMatch<'data>>> {
) -> Result<MissingObjectsInfo<'m, T>>
where
T: AsRef<[u8]>,
ChunkedObject<T>: ToAssemble,
{
let api = Api::current();
let request = difs
let request = objects
.iter()
.map(|d| d.to_assemble(options.pdbs_allowed))
.collect();
Expand All @@ -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::<BTreeMap<_, _>>();
Expand Down Expand Up @@ -1553,7 +1557,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_objects(&chunked, options)?;
upload_missing_chunks(&missing_info, chunk_options)?;

// Only if DIFs were missing, poll until assembling is complete
Expand Down

0 comments on commit 748d28d

Please sign in to comment.