|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-04-07 19:00 UTC] skuratovichalex at gmail dot com
Description: ------------ The essence of the problem is that when using the ZipArchive methods asynchronously, at the output I get the required archive, but only with the last processed file within the framework of asynchrony (To be more precise, the archive contains N / t files, where N is the total files to be added , t is the number of processing threads) PS-The initial presence of the archive does not change the situation. Example: (6 files) https://drive.google.com/file/d/1BAHn4iSElaADwfxQ_3_ZaTOmPKvggwH6/view?usp=sharing Test script: --------------- //one stream $za = new \ZipArchive(); ($za->open($zipFile, \ZipArchive::CREATE) !== TRUE) { throw new \Exception('Cannot create a zip file'); } $arFile = $dir . '/' . $newFileName . '.json'; $result = $za->addFromString($arFile, $stringData); $error = $za->getStatusString( ); $arIndex = $za->locateName($arFile); $arInfo = $za->statName($arFile); $closeResult = $za->close(); var_dump($error, $arIndex, $arInfo, $closeResult); Expected result: ---------------- file2 file1 file3 file4 string(8) "No error" int(0) array(8) { ["name"]=> string(17) "/order/file2.json" ["index"]=> int(0) ["crc"]=> int(0) ["size"]=> int(811758) ["mtime"]=> int(1617821517) ["comp_size"]=> int(811758) ["comp_method"]=> int(0) ["encryption_method"]=> int(0) } bool(true) string(8) "No error" int(0) array(8) { ["name"]=> string(17) "/order/file3.json" ["index"]=> int(0) ["crc"]=> int(0) ["size"]=> int(811758) ["mtime"]=> int(1617821517) ["comp_size"]=> int(811758) ["comp_method"]=> int(0) ["encryption_method"]=> int(0) } bool(true) string(8) "No error" int(0) array(8) { ["name"]=> string(17) "/order/file4.json" ["index"]=> int(0) ["crc"]=> int(0) ["size"]=> int(811758) ["mtime"]=> int(1617821517) ["comp_size"]=> int(811758) ["comp_method"]=> int(0) ["encryption_method"]=> int(0) } bool(true) string(8) "No error" int(0) array(8) { ["name"]=> string(17) "/order/file1.json" ["index"]=> int(0) ["crc"]=> int(0) ["size"]=> int(811758) ["mtime"]=> int(1617821517) ["comp_size"]=> int(811758) ["comp_method"]=> int(0) ["encryption_method"]=> int(0) } bool(true) Actual result: -------------- 4 JSON-files in ZIP-archive. Patchesasync-add-fromstring-wrong (last revision 2021-04-07 19:08 UTC by skuratovichalex at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 15:00:01 2025 UTC |
Try this: onDeviceReady.then(async function () { await howManyRecords(); console.log("after calling function records are: " + records);}. (https://www.hebpartnernet.org/)github.com