diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-08-13 16:26:42 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-08-19 16:38:08 +0300 |
commit | 4bc8601eb27992b0727428a9e8739ecd0a1abb3e (patch) | |
tree | b5c3d70a3225af18aee8f42f5de686c091daae75 /apps | |
parent | e9bd87af96bc2b85f7495e164f68da8ccf02b629 (diff) |
Return proper status when file didn't exist before
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/Upload/ChunkingPlugin.php | 4 | ||||
-rw-r--r-- | apps/dav/tests/unit/Upload/ChunkingPluginTest.php | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php index f3847d1ee1b..e2244a57826 100644 --- a/apps/dav/lib/Upload/ChunkingPlugin.php +++ b/apps/dav/lib/Upload/ChunkingPlugin.php @@ -22,6 +22,7 @@ namespace OCA\DAV\Upload; +use OCA\DAV\Connector\Sabre\Exception\Forbidden; use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; @@ -68,6 +69,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); @@ -86,7 +88,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 102eb727c3d..3dfc5d08314 100644 --- a/apps/dav/tests/unit/Upload/ChunkingPluginTest.php +++ b/apps/dav/tests/unit/Upload/ChunkingPluginTest.php @@ -100,8 +100,12 @@ class ChunkingPluginTest extends TestCase { ->method('nodeExists') ->with('target') ->will($this->returnValue(false)); - $this->response->expects($this->never()) - ->method('setStatus'); + $this->response->expects($this->once()) + ->method('setHeader') + ->with('Content-Length', '0'); + $this->response->expects($this->once()) + ->method('setStatus') + ->with(201); $this->request->expects($this->once()) ->method('getHeader') ->with('OC-Total-Length') |