diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-11-14 18:29:11 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2017-01-12 13:52:59 +0100 |
commit | e667b28298add5b6ecc6a3956bfb93cb4a047097 (patch) | |
tree | 88c6097f4d945a41d58226db2ebf5cebfe3503f5 /lib/private/Files/Node/File.php | |
parent | eb5ea0e260bf52dfc5752be76f6271d1c6f323c7 (diff) | |
download | nextcloud-server-e667b28298add5b6ecc6a3956bfb93cb4a047097.tar.gz nextcloud-server-e667b28298add5b6ecc6a3956bfb93cb4a047097.zip |
Fix files node API failed rename/copy
Whenever a rename or copy operation failed on the view, we must throw
an exception instead of just ignoring.
Signed-off-by: Vincent Petry <pvince81@owncloud.com>
Diffstat (limited to 'lib/private/Files/Node/File.php')
-rw-r--r-- | lib/private/Files/Node/File.php | 56 |
1 files changed, 10 insertions, 46 deletions
diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php index c4430b9181d..4bfa5d583f7 100644 --- a/lib/private/Files/Node/File.php +++ b/lib/private/Files/Node/File.php @@ -30,6 +30,16 @@ use OCP\Files\NotPermittedException; class File extends Node implements \OCP\Files\File { /** + * Creates a Folder that represents a non-existing path + * + * @param string $path path + * @return string non-existing node class + */ + protected function createNonExistingNode($path) { + return new NonExistingFile($this->root, $this->view, $path); + } + + /** * @return string * @throws \OCP\Files\NotPermittedException */ @@ -114,52 +124,6 @@ class File extends Node implements \OCP\Files\File { } /** - * @param string $targetPath - * @throws \OCP\Files\NotPermittedException - * @return \OC\Files\Node\Node - */ - public function copy($targetPath) { - $targetPath = $this->normalizePath($targetPath); - $parent = $this->root->get(dirname($targetPath)); - if ($parent instanceof Folder and $this->isValidPath($targetPath) and $parent->isCreatable()) { - $nonExisting = new NonExistingFile($this->root, $this->view, $targetPath); - $this->root->emit('\OC\Files', 'preCopy', array($this, $nonExisting)); - $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); - $this->view->copy($this->path, $targetPath); - $targetNode = $this->root->get($targetPath); - $this->root->emit('\OC\Files', 'postCopy', array($this, $targetNode)); - $this->root->emit('\OC\Files', 'postWrite', array($targetNode)); - return $targetNode; - } else { - throw new NotPermittedException(); - } - } - - /** - * @param string $targetPath - * @throws \OCP\Files\NotPermittedException - * @return \OC\Files\Node\Node - */ - public function move($targetPath) { - $targetPath = $this->normalizePath($targetPath); - $parent = $this->root->get(dirname($targetPath)); - if ($parent instanceof Folder and $this->isValidPath($targetPath) and $parent->isCreatable()) { - $nonExisting = new NonExistingFile($this->root, $this->view, $targetPath); - $this->root->emit('\OC\Files', 'preRename', array($this, $nonExisting)); - $this->root->emit('\OC\Files', 'preWrite', array($nonExisting)); - $this->view->rename($this->path, $targetPath); - $targetNode = $this->root->get($targetPath); - $this->root->emit('\OC\Files', 'postRename', array($this, $targetNode)); - $this->root->emit('\OC\Files', 'postWrite', array($targetNode)); - $this->path = $targetPath; - $this->fileInfo = null; - return $targetNode; - } else { - throw new NotPermittedException(); - } - } - - /** * @param string $type * @param bool $raw * @return string |