From: Thomas Müller Date: Tue, 24 Sep 2013 12:25:56 +0000 (+0200) Subject: adding error handling on file_put_contents within the web dav implementation X-Git-Tag: v6.0.0alpha2~77^2~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cf9dbc6e349bc287a414547944fd2a6dff383d64;p=nextcloud-server.git adding error handling on file_put_contents within the web dav implementation --- diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index 3181a4b310f..0717d952268 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -72,7 +72,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa // mark file as partial while uploading (ignored by the scanner) $partpath = $newPath . '.part'; - \OC\Files\Filesystem::file_put_contents($partpath, $data); + $putOkay = \OC\Files\Filesystem::file_put_contents($partpath, $data); + if ($putOkay === false) { + \OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR); + \OC\Files\Filesystem::unlink($partpath); + throw new Sabre_DAV_Exception(); + } //detect aborted upload if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) { diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index 61bdcd5e0ae..57ba94c7b19 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -58,7 +58,12 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D // mark file as partial while uploading (ignored by the scanner) $partpath = $this->path . '.part'; - \OC\Files\Filesystem::file_put_contents($partpath, $data); + $putOkay = \OC\Files\Filesystem::file_put_contents($partpath, $data); + if ($putOkay === false) { + \OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR); + \OC\Files\Filesystem::unlink($partpath); + throw new Sabre_DAV_Exception(); + } //detect aborted upload if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {