Delete chunks if the move on an upload failed
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
7e16867b29
commit
242b19f18e
|
@ -26,6 +26,7 @@
|
||||||
namespace OCA\DAV\Upload;
|
namespace OCA\DAV\Upload;
|
||||||
|
|
||||||
use OCA\DAV\Connector\Sabre\Directory;
|
use OCA\DAV\Connector\Sabre\Directory;
|
||||||
|
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
|
||||||
use Sabre\DAV\Exception\BadRequest;
|
use Sabre\DAV\Exception\BadRequest;
|
||||||
use Sabre\DAV\Exception\NotFound;
|
use Sabre\DAV\Exception\NotFound;
|
||||||
use Sabre\DAV\INode;
|
use Sabre\DAV\INode;
|
||||||
|
@ -87,13 +88,16 @@ class ChunkingPlugin extends ServerPlugin {
|
||||||
* @return bool|void false to stop handling, void to skip this handler
|
* @return bool|void false to stop handling, void to skip this handler
|
||||||
*/
|
*/
|
||||||
public function performMove($path, $destination) {
|
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
|
// 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)
|
// trigger all default events (copied from CorePlugin::move)
|
||||||
$this->server->emit('afterMove', [$path, $destination]);
|
$this->server->emit('afterMove', [$path, $destination]);
|
||||||
|
|
Loading…
Reference in New Issue