]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge branch 'master' into move-aborted-upload-detection-into-plugin-master
authorThomas Müller <thomas.mueller@tmit.eu>
Mon, 30 Sep 2013 07:21:37 +0000 (09:21 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 30 Sep 2013 07:21:37 +0000 (09:21 +0200)
1  2 
lib/connector/sabre/directory.php

index 29374f7a6cf44d9dd1be36b3feda2b87c0746b96,a50098df793dcfcff7fb3c182633f2c08536eb17..382bdf06df1f272e311e5fd2e0fca8f30f539860
@@@ -74,8 -74,27 +74,14 @@@ class OC_Connector_Sabre_Directory exte
  
                        \OC\Files\Filesystem::file_put_contents($partpath, $data);
  
 -                      //detect aborted upload
 -                      if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
 -                              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, $newPath);
+                       $renameOkay = \OC\Files\Filesystem::rename($partpath, $newPath);
+                       $fileExists = \OC\Files\Filesystem::file_exists($newPath);
+                       if ($renameOkay === false || $fileExists === false) {
+                               \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
+                               \OC\Files\Filesystem::unlink($partpath);
+                               throw new Sabre_DAV_Exception();
+                       }
  
                        // allow sync clients to send the mtime along in a header
                        $mtime = OC_Request::hasModificationTime();