mirror of
https://github.com/nextcloud/server.git
synced 2026-06-12 02:00:51 -04:00
Return proper status when file didn't exist before
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
e9bd87af96
commit
4bc8601eb2
2 changed files with 9 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue