Skip to content

Commit 1ca5259

Browse files
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
1 parent c2c893d commit 1ca5259

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/utils/dif_upload.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,12 +1212,16 @@ fn create_il2cpp_mappings<'a>(difs: &[DifMatch<'a>]) -> Result<Vec<DifMatch<'a>>
12121212
///
12131213
/// The returned value contains separate vectors for incomplete DIFs and
12141214
/// missing chunks for convenience.
1215-
fn try_assemble_difs<'data, 'm>(
1216-
difs: &'m [Chunked<DifMatch<'data>>],
1215+
fn try_assemble<'m, T>(
1216+
objects: &'m [Chunked<T>],
12171217
options: &DifUpload,
1218-
) -> Result<MissingObjectsInfo<'m, DifMatch<'data>>> {
1218+
) -> Result<MissingObjectsInfo<'m, T>>
1219+
where
1220+
T: AsRef<[u8]>,
1221+
Chunked<T>: ToAssemble,
1222+
{
12191223
let api = Api::current();
1220-
let request = difs
1224+
let request = objects
12211225
.iter()
12221226
.map(|d| d.to_assemble(options.pdbs_allowed))
12231227
.collect();
@@ -1231,7 +1235,7 @@ fn try_assemble_difs<'data, 'm>(
12311235
// performed twice with the same data. While this is redundant, it is also
12321236
// fast enough and keeping it here makes the `try_assemble_difs` interface
12331237
// nicer.
1234-
let difs_by_checksum = difs
1238+
let difs_by_checksum = objects
12351239
.iter()
12361240
.map(|m| (m.checksum(), m))
12371241
.collect::<BTreeMap<_, _>>();
@@ -1550,7 +1554,7 @@ fn upload_difs_chunked(
15501554
})?;
15511555

15521556
// Upload missing chunks to the server and remember incomplete difs
1553-
let missing_info = try_assemble_difs(&chunked, options)?;
1557+
let missing_info = try_assemble(&chunked, options)?;
15541558
upload_missing_chunks(&missing_info, chunk_options)?;
15551559

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

0 commit comments

Comments
 (0)