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

1  2 
lib/connector/sabre/directory.php

index 8a092c2455aaff0ff888f92c144b2ee0ff0b51b2,a50098df793dcfcff7fb3c182633f2c08536eb17..ddeef271a5b08477022dabd258233f953f7946a2
@@@ -55,40 -55,59 +55,46 @@@ class OC_Connector_Sabre_Directory exte
                }
  
                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);
 -
 -                      //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);
 -                                      }
 -                              }
 -                      }
 +                      return $this->createFileChunked($name, $data);
 +              }
 +              $newPath = $this->path . '/' . $name;
  
 -                      // 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();
 -                      }
 +              // mark file as partial while uploading (ignored by the scanner)
 +              $partpath = $newPath . '.part';
 +
 +              \OC\Files\Filesystem::file_put_contents($partpath, $data);
  
 -                      // 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');
 +              //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);
                                }
                        }
 +              }
  
 -                      return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
 +              // 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();
+               }
  
 -              return null;
 +              // 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);
        }
  
        /**