mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
Detect aborted connection in OC\Files\View and stop writing data to the
output buffer Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
02e009867b
commit
b7d82f7c01
2 changed files with 10 additions and 3 deletions
|
|
@ -430,6 +430,7 @@ class View {
|
|||
$chunkSize = 524288; // 512 kB chunks
|
||||
while (!feof($handle)) {
|
||||
echo fread($handle, $chunkSize);
|
||||
$this->checkConnectionStatus();
|
||||
flush();
|
||||
}
|
||||
fclose($handle);
|
||||
|
|
@ -482,6 +483,7 @@ class View {
|
|||
$len = $chunkSize;
|
||||
}
|
||||
echo fread($handle, $len);
|
||||
$this->checkConnectionStatus();
|
||||
flush();
|
||||
}
|
||||
return ftell($handle) - $from;
|
||||
|
|
@ -492,6 +494,14 @@ class View {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
private function checkConnectionStatus(): void {
|
||||
$connectionStatus = \connection_status();
|
||||
if ($connectionStatus !== 0) {
|
||||
throw new \RuntimeException("Connection lost. Status: $connectionStatus");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return mixed
|
||||
|
|
|
|||
|
|
@ -235,9 +235,6 @@ class OC_Files {
|
|||
OC::$server->getLogger()->logException($ex);
|
||||
$l = \OC::$server->getL10N('lib');
|
||||
$hint = method_exists($ex, 'getHint') ? $ex->getHint() : '';
|
||||
if ($event && $event->getErrorMessage() !== null) {
|
||||
$hint .= ' ' . $event->getErrorMessage();
|
||||
}
|
||||
\OC_Template::printErrorPage($l->t('Cannot download file'), $hint, 200);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue