From e0538fcf194b15ca5e9e56e32f53b1c8080d7ca0 Mon Sep 17 00:00:00 2001 From: Ash-Shiddiqul Akbar Hidayat Date: Wed, 19 Jun 2024 13:39:36 +0700 Subject: [PATCH] we need to update the datasize everythime ->data is updated --- src/LzwStreamWrapper.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/LzwStreamWrapper.php b/src/LzwStreamWrapper.php index 5b59940..5598f14 100644 --- a/src/LzwStreamWrapper.php +++ b/src/LzwStreamWrapper.php @@ -274,6 +274,7 @@ public function stream_close() if (file_exists($this->tmp2)) unlink($this->tmp2); } else { $this->data = null; + $this->dataSize = 0; } } @@ -339,6 +340,7 @@ public function stream_write($data) $postfix = substr($this->data, ($this->pointer + $count)); $this->data = $prefix.$data.$postfix; $this->pointer += $count; + $this->dataSize = strlen($this->data); return $count; } @@ -396,6 +398,7 @@ public function stream_truncate($new_size) } elseif ($new_size < $actual_data_size) { if ($this->tmp === null) { $this->data = substr($this->data, 0, $new_size); + $this->dataSize = strlen($this->data); $this->writtenBytes = $new_size; } else { $fp = fopen($this->tmp, 'w'.(strpos($this->mode, 'b') !== 0