Skip to content

Commit 0e45c99

Browse files
juliusknorrMorrisJobke
authored andcommitted
Delete chunks if the move on an upload failed
Signed-off-by: Julius Härtl <jus@bitgrid.net>
1 parent ccb1675 commit 0e45c99

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

apps/dav/lib/Upload/ChunkingPlugin.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
namespace OCA\DAV\Upload;
2727

2828
use OCA\DAV\Connector\Sabre\Directory;
29+
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
2930
use Sabre\DAV\Exception\BadRequest;
3031
use Sabre\DAV\Exception\NotFound;
3132
use Sabre\DAV\INode;
@@ -87,13 +88,16 @@ public function beforeMove($sourcePath, $destination) {
8788
* @return bool|void false to stop handling, void to skip this handler
8889
*/
8990
public function performMove($path, $destination) {
90-
if (!$this->server->tree->nodeExists($destination)) {
91-
// skip and let the default handler do its work
92-
return;
93-
}
94-
9591
// do a move manually, skipping Sabre's default "delete" for existing nodes
96-
$this->server->tree->move($path, $destination);
92+
try {
93+
$this->server->tree->move($path, $destination);
94+
} catch (Forbidden $e) {
95+
$sourceNode = $this->server->tree->getNodeForPath($path);
96+
if ($sourceNode instanceof FutureFile) {
97+
$sourceNode->delete();
98+
}
99+
throw $e;
100+
}
97101

98102
// trigger all default events (copied from CorePlugin::move)
99103
$this->server->emit('afterMove', [$path, $destination]);

0 commit comments

Comments
 (0)