diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-02-10 18:17:10 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-02-11 09:53:07 +0100 |
commit | 2cb2991c049387290d6ba71a08381aeac4de2fe3 (patch) | |
tree | aef8de445b32c781ba2737dc211c63c3cbf1e0c1 /lib/connector/sabre/directory.php | |
parent | 15ab2fd52aa3d2971682406a0add82ba453f82f6 (diff) | |
download | nextcloud-server-2cb2991c049387290d6ba71a08381aeac4de2fe3.tar.gz nextcloud-server-2cb2991c049387290d6ba71a08381aeac4de2fe3.zip |
delete partial file when file upload is aborted
Diffstat (limited to 'lib/connector/sabre/directory.php')
-rw-r--r-- | lib/connector/sabre/directory.php | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index a5676d656ec..f9245115353 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -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 |