aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Upload/ChunkingPlugin.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-08-13 20:47:08 +0200
committerGitHub <noreply@github.com>2020-08-13 20:47:08 +0200
commite9f5c7f649b923ec45d7a37eb24369e11727ccbf (patch)
treee978e971c21d7f5509178c6053ff201f3f4aea31 /apps/dav/lib/Upload/ChunkingPlugin.php
parented461155930219c2de3a648e7dfdf75778af2f7a (diff)
parent6722246aca71e392ab54600a3c91750075a595f2 (diff)
downloadnextcloud-server-e9f5c7f649b923ec45d7a37eb24369e11727ccbf.tar.gz
nextcloud-server-e9f5c7f649b923ec45d7a37eb24369e11727ccbf.zip
Merge pull request #22128 from nextcloud/bugfix/noid/cleanup-chunks-on-failure
Delete chunks if the move on an upload failed
Diffstat (limited to 'apps/dav/lib/Upload/ChunkingPlugin.php')
-rw-r--r--apps/dav/lib/Upload/ChunkingPlugin.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php
index 0a89b144ae1..6dd05c24ebf 100644
--- a/apps/dav/lib/Upload/ChunkingPlugin.php
+++ b/apps/dav/lib/Upload/ChunkingPlugin.php
@@ -26,6 +26,7 @@
namespace OCA\DAV\Upload;
use OCA\DAV\Connector\Sabre\Directory;
+use OCA\DAV\Connector\Sabre\Exception\Forbidden;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\INode;
@@ -87,13 +88,17 @@ class ChunkingPlugin extends ServerPlugin {
* @return bool|void false to stop handling, void to skip this handler
*/
public function performMove($path, $destination) {
- if (!$this->server->tree->nodeExists($destination)) {
- // skip and let the default handler do its work
- return;
- }
-
+ $fileExists = $this->server->tree->nodeExists($destination);
// do a move manually, skipping Sabre's default "delete" for existing nodes
- $this->server->tree->move($path, $destination);
+ try {
+ $this->server->tree->move($path, $destination);
+ } catch (Forbidden $e) {
+ $sourceNode = $this->server->tree->getNodeForPath($path);
+ if ($sourceNode instanceof FutureFile) {
+ $sourceNode->delete();
+ }
+ throw $e;
+ }
// trigger all default events (copied from CorePlugin::move)
$this->server->emit('afterMove', [$path, $destination]);
@@ -102,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;
}