Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ZipStreamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public function addFileFromStream($stream, $filePath, $options = NULL) {

list($gpFlags, $lfhLength) = $this->beginFile($filePath, False, $options['comment'], $options['timestamp'], $gpFlags, $options['compress']);
list($dataLength, $gzLength, $dataCRC32) = $this->streamFileData($stream, $options['compress'], $options['level']);
if($dataLength === 0) {
// Handle invalid result
return false;
}

$ddLength = $this->addDataDescriptor($dataLength, $gzLength, $dataCRC32);

Expand Down Expand Up @@ -366,6 +370,12 @@ private function streamFileData($stream, $compress, $level) {
$this->write($data);

$this->flush();

// Before potentially reading the next chunk, check if user aborted the connection.
// Ignored (not aborted), when ignore_user_abort is set.
if (connection_aborted() === 1 && ignore_user_abort() === 0) {
return array(0, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about throwing an exception here? The first element is expected to be an Count64 instance.

}
}
if (COMPR::DEFLATE === $compress) {
$data = $compStream->finish();
Expand Down