summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-08-06 11:50:31 +0200
committerJulius Härtl <jus@bitgrid.net>2020-08-12 08:18:46 +0200
commit860f6d8fcf50d8d7028ee503d00eef42472ae9e2 (patch)
treec9f9e30bfa5ebcec0548112a37063a44a2c1bcca /apps/dav/lib
parentad6a4219a2388cbe7784faddad1d21e2aff5a013 (diff)
downloadnextcloud-server-860f6d8fcf50d8d7028ee503d00eef42472ae9e2.tar.gz
nextcloud-server-860f6d8fcf50d8d7028ee503d00eef42472ae9e2.zip
Delete chunks if the move on an upload failed
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Upload/ChunkingPlugin.php16
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php
index 0a89b144ae1..d9b4ee44d39 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,16 @@ 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;
- }
-
// 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]);