delete partial file when file upload is aborted

This commit is contained in:
Jörn Friedrich Dreyer 2013-02-10 18:17:10 +01:00
parent 15ab2fd52a
commit 2cb2991c04
2 changed files with 17 additions and 14 deletions

View File

@ -69,13 +69,14 @@ 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)
);
if (isset($_SERVER['CONTENT_LENGTH'])) {
$expected = $_SERVER['CONTENT_LENGTH'];
$actual = \OC\Files\Filesystem::filesize($partpath);
if ($actual != $expected) {
\OC\Files\Filesystem::unlink($partpath);
throw new Sabre_DAV_Exception_BadRequest(
'expected filesize ' . $expected . ' got ' . $actual);
}
}
// rename to correct path

View File

@ -51,14 +51,16 @@ 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)
);
if (isset($_SERVER['CONTENT_LENGTH'])) {
$expected = $_SERVER['CONTENT_LENGTH'];
$actual = \OC\Files\Filesystem::filesize($partpath);
if ($actual != $expected) {
\OC\Files\Filesystem::unlink($partpath);
throw new Sabre_DAV_Exception_BadRequest(
'expected filesize ' . $expected . ' got ' . $actual);
}
}
// rename to correct path
\OC\Files\Filesystem::rename($partpath, $this->path);