Fixing bug in fmt3 patching routine
Publish PHP Package / docker (push) Successful in 6s
Details
Publish PHP Package / docker (push) Successful in 6s
Details
This commit is contained in:
parent
2b0d2e0a4f
commit
7b9e1764d9
12
pack.inc.php
12
pack.inc.php
|
@ -458,18 +458,20 @@ function _config_patch_bundle_fmt3(
|
||||||
$chunk_entries = array_filter($header, fn($item) => $item[4] == $chunk_offset);
|
$chunk_entries = array_filter($header, fn($item) => $item[4] == $chunk_offset);
|
||||||
|
|
||||||
//chunk contains only one patch entry
|
//chunk contains only one patch entry
|
||||||
$patched_chunk = lz4_compress($patch_payload, 9);
|
$patch_payload_lz4 = lz4_compress($patch_payload, 9);
|
||||||
if(strlen($patched_chunk) > $max_chunk_size)
|
$patched_chunk = pack("V", strlen($patch_payload_lz4));
|
||||||
$max_chunk_size = strlen($patched_chunk);
|
$patched_chunk .= $patch_payload_lz4;
|
||||||
|
if(strlen($patch_payload) > $max_chunk_size)
|
||||||
|
$max_chunk_size = strlen($patch_payload);
|
||||||
|
|
||||||
//TODO: make a better generic algorithm for patching the whole chunk
|
//TODO: make a better generic algorithm for patching the whole chunk
|
||||||
//special case for single entry
|
//special case for single entry
|
||||||
if(count($chunk_entries) == 1 && $payloads_offset == 0)
|
if(count($chunk_entries) == 1 && $payloads_offset == 0)
|
||||||
{
|
{
|
||||||
$lz4_chunk_size = unpack("V", substr($packed_data, $chunk_offset, 4))[1];
|
$lz4_chunk_size = unpack("V", substr($payloads_bundle, $chunk_offset, 4))[1];
|
||||||
|
|
||||||
//we can just replace chunk in place if the size of a patched chunk is less or equal
|
//we can just replace chunk in place if the size of a patched chunk is less or equal
|
||||||
if(strlen($patched_chunk) <= $lz4_chunk_size)
|
if(strlen($patch_payload_lz4) <= $lz4_chunk_size)
|
||||||
{
|
{
|
||||||
$payloads_bundle = substr_replace($payloads_bundle, $patched_chunk, $chunk_offset, strlen($patched_chunk));
|
$payloads_bundle = substr_replace($payloads_bundle, $patched_chunk, $chunk_offset, strlen($patched_chunk));
|
||||||
$header_entry[6] = strlen($patch_payload);
|
$header_entry[6] = strlen($patch_payload);
|
||||||
|
|
Loading…
Reference in New Issue