Apply suggestions from code review in View.php

Co-authored-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2023-09-05 11:31:00 +02:00 committed by backportbot-nextcloud[bot]
parent ea2b28e1fc
commit 342cb33f71

View file

@ -428,11 +428,11 @@ class View {
}
$handle = $this->fopen($path, 'rb');
if ($handle) {
$chunkSize = 524288; // 512 kB chunks
$chunkSize = 524288; // 512 kiB chunks
while (!feof($handle)) {
echo fread($handle, $chunkSize);
$this->checkConnectionStatus();
flush();
$this->checkConnectionStatus();
}
fclose($handle);
return $this->filesize($path);
@ -484,8 +484,8 @@ class View {
$len = $chunkSize;
}
echo fread($handle, $len);
$this->checkConnectionStatus();
flush();
$this->checkConnectionStatus();
}
return ftell($handle) - $from;
}
@ -498,7 +498,7 @@ class View {
private function checkConnectionStatus(): void {
$connectionStatus = \connection_status();
if ($connectionStatus !== 0) {
if ($connectionStatus !== CONNECTION_NORMAL) {
throw new ConnectionLostException("Connection lost. Status: $connectionStatus");
}
}