]> source.dussan.org Git - nextcloud-server.git/commitdiff
Return proper status when file didn't exist before 22128/head
authorJulius Härtl <jus@bitgrid.net>
Thu, 13 Aug 2020 13:26:42 +0000 (15:26 +0200)
committerJulius Härtl <jus@bitgrid.net>
Thu, 13 Aug 2020 13:26:42 +0000 (15:26 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/dav/lib/Upload/ChunkingPlugin.php
apps/dav/tests/unit/Upload/ChunkingPluginTest.php

index d9b4ee44d3944d8ad3d7615d0a6c583103c85e54..6dd05c24ebf77159e841ffdcc26c429b0f2bd785 100644 (file)
@@ -88,6 +88,7 @@ class ChunkingPlugin extends ServerPlugin {
         * @return bool|void false to stop handling, void to skip this handler
         */
        public function performMove($path, $destination) {
+               $fileExists = $this->server->tree->nodeExists($destination);
                // do a move manually, skipping Sabre's default "delete" for existing nodes
                try {
                        $this->server->tree->move($path, $destination);
@@ -106,7 +107,7 @@ class ChunkingPlugin extends ServerPlugin {
 
                $response = $this->server->httpResponse;
                $response->setHeader('Content-Length', '0');
-               $response->setStatus(204);
+               $response->setStatus($fileExists ? 204 : 201);
 
                return false;
        }
index d81c1eaf5046ea97d25021628b08394031ac59bd..060a7fdadd57574e311e71a0c30b91c392da46b5 100644 (file)
@@ -133,7 +133,7 @@ class ChunkingPluginTest extends TestCase {
                        ->with('Content-Length', '0');
                $this->response->expects($this->once())
                        ->method('setStatus')
-                       ->with(204);
+                       ->with(201);
                $this->request->expects($this->once())
                        ->method('getHeader')
                        ->with('OC-Total-Length')