check Content-Length to detect aborted uploads

This commit is contained in:
Jörn Friedrich Dreyer 2013-02-10 17:09:31 +01:00
parent 806522d007
commit 15ab2fd52a
2 changed files with 19 additions and 0 deletions

View File

@ -68,6 +68,16 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
\OC\Files\Filesystem::file_put_contents($partpath, $data);
//detect aborted upload
if (isset($_SERVER['CONTENT_LENGTH'])
&& \OC\Files\Filesystem::filesize($partpath) != $_SERVER['CONTENT_LENGTH'])
{
throw new Sabre_DAV_Exception_BadRequest(
'expected filesize ' . $_SERVER['CONTENT_LENGTH'].
' got ' . \OC\Files\Filesystem::filesize($partpath)
);
}
// rename to correct path
\OC\Files\Filesystem::rename($partpath, $newPath);

View File

@ -50,6 +50,15 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
\OC\Files\Filesystem::file_put_contents($partpath, $data);
//detect aborted upload
if (isset($_SERVER['CONTENT_LENGTH'])
&& \OC\Files\Filesystem::filesize($partpath) != $_SERVER['CONTENT_LENGTH'])
{
throw new Sabre_DAV_Exception_BadRequest(
'expected filesize ' . $_SERVER['CONTENT_LENGTH'].
' got ' . \OC\Files\Filesystem::filesize($partpath)
);
}
// rename to correct path
\OC\Files\Filesystem::rename($partpath, $this->path);