Skip to content

Commit

Permalink
Delete chunks if the move on an upload failed
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Aug 6, 2020
1 parent cb1d9cf commit 0508b15
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions apps/dav/lib/Upload/ChunkingPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ public function beforeMove($sourcePath, $destination) {
* @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 (\Exception $e) {
$sourceNode = $this->server->tree->getNodeForPath($path);
if ($sourceNode instanceof FutureFile) {
$sourceNode->delete();
}
}

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

0 comments on commit 0508b15

Please sign in to comment.