From: Julius Härtl Date: Thu, 13 Aug 2020 13:26:42 +0000 (+0200) Subject: Return proper status when file didn't exist before X-Git-Tag: v20.0.0beta1~74^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F22128%2Fhead;p=nextcloud-server.git Return proper status when file didn't exist before Signed-off-by: Julius Härtl --- diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php index d9b4ee44d39..6dd05c24ebf 100644 --- a/apps/dav/lib/Upload/ChunkingPlugin.php +++ b/apps/dav/lib/Upload/ChunkingPlugin.php @@ -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; } diff --git a/apps/dav/tests/unit/Upload/ChunkingPluginTest.php b/apps/dav/tests/unit/Upload/ChunkingPluginTest.php index d81c1eaf504..060a7fdadd5 100644 --- a/apps/dav/tests/unit/Upload/ChunkingPluginTest.php +++ b/apps/dav/tests/unit/Upload/ChunkingPluginTest.php @@ -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')