]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge branch 'master' into fixing-4011-master
authorThomas Müller <thomas.mueller@tmit.eu>
Mon, 30 Sep 2013 09:36:08 +0000 (11:36 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 30 Sep 2013 09:36:08 +0000 (11:36 +0200)
Conflicts:
lib/connector/sabre/directory.php

1  2 
lib/connector/sabre/directory.php
lib/connector/sabre/file.php

index e36ac84652c685e71965132dde7046673b66769d,382bdf06df1f272e311e5fd2e0fca8f30f539860..af0dfd70f08e32670285c5e5ba5544de5091beda
@@@ -54,9 -54,47 +54,10 @@@ class OC_Connector_Sabre_Directory exte
                        throw new \Sabre_DAV_Exception_Forbidden();
                }
  
 -              if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
 -                      $info = OC_FileChunking::decodeName($name);
 -                      if (empty($info)) {
 -                              throw new Sabre_DAV_Exception_NotImplemented();
 -                      }
 -                      $chunk_handler = new OC_FileChunking($info);
 -                      $chunk_handler->store($info['index'], $data);
 -                      if ($chunk_handler->isComplete()) {
 -                              $newPath = $this->path . '/' . $info['name'];
 -                              $chunk_handler->file_assemble($newPath);
 -                              return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
 -                      }
 -              } else {
 -                      $newPath = $this->path . '/' . $name;
 -
 -                      // mark file as partial while uploading (ignored by the scanner)
 -                      $partpath = $newPath . '.part';
 -
 -                      \OC\Files\Filesystem::file_put_contents($partpath, $data);
 -
 -                      // rename to correct path
 -                      $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();
 -                      if ($mtime !== false) {
 -                              if(\OC\Files\Filesystem::touch($newPath, $mtime)) {
 -                                      header('X-OC-MTime: accepted');
 -                              }
 -                      }
 -
 -                      return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
 -              }
 +              $path = $this->path . '/' . $name;
 +              $node = new OC_Connector_Sabre_File($path);
 +              return $node->put($data);
 -              return null;
        }
  
        /**
index b05c9fcb92a8e6678639ee85788e3b35e61bdb00,433b11485523f786851d20a9c8e9292f94379af3..8ffec371e3f4e94a2589fc300a3e88105129c7bb
@@@ -78,37 -58,27 +78,24 @@@ class OC_Connector_Sabre_File extends O
                // mark file as partial while uploading (ignored by the scanner)
                $partpath = $this->path . '.part';
  
 -              \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);
 -                              }
 +              try {
 +                      $putOkay = $fs->file_put_contents($partpath, $data);
 +                      if ($putOkay === false) {
 +                              \OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR);
 +                              $fs->unlink($partpath);
 +                              // because we have no clue about the cause we can only throw back a 500/Internal Server Error
 +                              throw new Sabre_DAV_Exception();
                        }
 +              } catch (\OCP\Files\NotPermittedException $e) {
 +                      throw new Sabre_DAV_Exception_Forbidden();
                }
  
-               //detect aborted upload
-               if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
-                       if (isset($_SERVER['CONTENT_LENGTH'])) {
-                               $expected = $_SERVER['CONTENT_LENGTH'];
-                               $actual = $fs->filesize($partpath);
-                               if ($actual != $expected) {
-                                       $fs->unlink($partpath);
-                                       throw new Sabre_DAV_Exception_BadRequest(
-                                               'expected filesize ' . $expected . ' got ' . $actual);
-                               }
-                       }
-               }
                // rename to correct path
 -              $renameOkay = \OC\Files\Filesystem::rename($partpath, $this->path);
 -              $fileExists = \OC\Files\Filesystem::file_exists($this->path);
 +              $renameOkay = $fs->rename($partpath, $this->path);
 +              $fileExists = $fs->file_exists($this->path);
                if ($renameOkay === false || $fileExists === false) {
                        \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR);
 -                      \OC\Files\Filesystem::unlink($partpath);
 +                      $fs->unlink($partpath);
                        throw new Sabre_DAV_Exception();
                }
  
         *
         * An ETag is a unique identifier representing the current version of the
         * file. If the file changes, the ETag MUST change.  The ETag is an
--       * arbritrary string, but MUST be surrounded by double-quotes.
++       * arbitrary string, but MUST be surrounded by double-quotes.
         *
         * Return null if the ETag can not effectively be determined
         *