]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding error handling on file_put_contents within the web dav implementation
authorThomas Müller <thomas.mueller@tmit.eu>
Tue, 24 Sep 2013 12:25:56 +0000 (14:25 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 24 Sep 2013 12:25:56 +0000 (14:25 +0200)
lib/connector/sabre/directory.php
lib/connector/sabre/file.php

index 3181a4b310f06515a1504ff14708f16c1c6fcbb2..0717d952268feb1dfd4c42f265a04c496d19d9c7 100644 (file)
@@ -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' ) {
index 61bdcd5e0ae297f37eeadf067f6667a99b524cd5..57ba94c7b1948886784a0d121983a35b36c61a4b 100644 (file)
@@ -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') {