]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding OC-ETag header
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 29 Aug 2014 10:09:33 +0000 (12:09 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 24 Mar 2015 20:36:46 +0000 (21:36 +0100)
lib/private/connector/sabre/file.php
lib/private/connector/sabre/filesplugin.php

index 8f0642d794a7a92bf88d3b784fe19b6656a6875e..bb68f44672578e949e3661b67ca7f34336edab26 100644 (file)
@@ -247,8 +247,7 @@ class File extends \OC\Connector\Sabre\Node implements \Sabre\DAV\IFile {
         * @throws \Sabre\DAV\Exception\NotImplemented
         * @throws \Sabre\DAV\Exception\ServiceUnavailable
         */
-       private function createFileChunked($data)
-       {
+       private function createFileChunked($data) {
                list($path, $name) = \Sabre\HTTP\URLUtil::splitPath($this->path);
 
                $info = \OC_FileChunking::decodeName($name);
@@ -305,6 +304,8 @@ class File extends \OC\Connector\Sabre\Node implements \Sabre\DAV\IFile {
                                        }
                                }
 
+                               // mark chunking complete
+                               $_SERVER['X-CHUNKING_COMPLETE'] = true;
                                $info = $this->fileView->getFileInfo($targetPath);
                                return $info->getEtag();
                        } catch (\OCP\Files\StorageNotAvailableException $e) {
index 9720519f4c7ae4de2af4cc9a8d7f01533fc161b7..e03cac9c537772fa6033a6ce13b8ef982d8175b4 100644 (file)
@@ -174,7 +174,24 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin {
                        if (!is_null($fileId)) {
                                $this->server->httpResponse->setHeader('OC-FileId', $fileId);
                        }
+                       $eTag = $this->getETag($node);
+                       if (!is_null($eTag)) {
+                               $this->server->httpResponse->setHeader('OC-ETag', $eTag);
+                       }
+               }
+       }
+
+       /**
+        * @param \OC\Connector\Sabre\Node $node
+        */
+       private function getETag($node) {
+               if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
+                       if (isset($_SERVER['X-CHUNKING_COMPLETE'])) {
+                               return $node->getETag();
+                       }
+                       return null;
                }
+               return $node->getETag();
        }
 
 }