Merge pull request #10862 from chli1/master

fix BadRequest error if CONTENT_LENGTH not set
This commit is contained in:
Vincent Petry 2014-09-08 10:00:15 +02:00
commit 637cff68ac
1 changed files with 8 additions and 5 deletions

View File

@ -102,13 +102,16 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements \Sabre\
throw new OC_Connector_Sabre_Exception_FileLocked($e->getMessage(), $e->getCode(), $e); throw new OC_Connector_Sabre_Exception_FileLocked($e->getMessage(), $e->getCode(), $e);
} }
// if content length is sent by client:
// double check if the file was fully received // double check if the file was fully received
// compare expected and actual size // compare expected and actual size
$expected = $_SERVER['CONTENT_LENGTH']; if (isset($_SERVER['CONTENT_LENGTH'])) {
$actual = $this->fileView->filesize($partFilePath); $expected = $_SERVER['CONTENT_LENGTH'];
if ($actual != $expected) { $actual = $this->fileView->filesize($partFilePath);
$this->fileView->unlink($partFilePath); if ($actual != $expected) {
throw new \Sabre\DAV\Exception\BadRequest('expected filesize ' . $expected . ' got ' . $actual); $this->fileView->unlink($partFilePath);
throw new \Sabre\DAV\Exception\BadRequest('expected filesize ' . $expected . ' got ' . $actual);
}
} }
// rename to correct path // rename to correct path