fix(files): decrement quota by actual bytes written in stream_write

The quota is now decremented by the actual number of bytes written ($written) rather than the intended size.

This ensures quota tracking stays accurate even if fwrite writes fewer (or more - i.e. from underlying buffering/etc) bytes than requested.

Signed-off-by: Josh <josh.t.richards@gmail.com>
This commit is contained in:
Josh 2025-10-13 18:26:48 -04:00 committed by GitHub
parent 692d265d4a
commit bd43cb7d04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -78,7 +78,10 @@ class Quota extends Wrapper {
$data = substr($data, 0, $this->limit);
$size = $this->limit;
}
$this->limit -= $size;
return fwrite($this->source, $data);
$written = fwrite($this->source, $data);
// Decrement quota by the actual number of bytes written ($written),
// not the intended size
$this->limit -= $written;
return $written;
}
}