]> source.dussan.org Git - nextcloud-server.git/commitdiff
Delete chunks if the move on an upload failed
authorJulius Härtl <jus@bitgrid.net>
Thu, 6 Aug 2020 09:50:31 +0000 (11:50 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 13 Aug 2020 18:55:10 +0000 (18:55 +0000)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/dav/lib/Upload/ChunkingPlugin.php

index 704cbf8f578bf616aba97ac22c2fbf33a763a2fd..74892aaffde9ce905acc69af6d8f11db1ad19356 100644 (file)
@@ -69,13 +69,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]);