diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-06-30 18:27:55 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-06-30 18:37:47 +0200 |
commit | fe0de5fc10f61a7bb3173a04a986b145789b9160 (patch) | |
tree | f24f9107c580b90108ba5d75359d0a2fbc0b9c16 /lib/connector/sabre | |
parent | 4e55d0ef9be67efaacefbba720ef1dbce67d6ede (diff) | |
download | nextcloud-server-fe0de5fc10f61a7bb3173a04a986b145789b9160.tar.gz nextcloud-server-fe0de5fc10f61a7bb3173a04a986b145789b9160.zip |
improved move operation for sabre's objecttree
Diffstat (limited to 'lib/connector/sabre')
-rw-r--r-- | lib/connector/sabre/objecttree.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/connector/sabre/objecttree.php b/lib/connector/sabre/objecttree.php index 23cbd20cf4e..f51b991d12a 100644 --- a/lib/connector/sabre/objecttree.php +++ b/lib/connector/sabre/objecttree.php @@ -46,4 +46,28 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { return $node; } + + /** + * Moves a file from one location to another + * + * @param string $sourcePath The path to the file which should be moved + * @param string $destinationPath The full destination path, so not just the destination parent node + * @throws \Sabre_DAV_Exception_Forbidden + * @return int + */ + public function move($sourcePath, $destinationPath) { + + $sourceNode = $this->getNodeForPath($sourcePath); + if ($sourceNode instanceof \Sabre_DAV_ICollection and $this->nodeExists($destinationPath)) { + throw new \Sabre_DAV_Exception_Forbidden('Could not copy directory ' . $sourceNode . ', target exists'); + } + list($sourceDir,) = \Sabre_DAV_URLUtil::splitPath($sourcePath); + list($destinationDir,) = \Sabre_DAV_URLUtil::splitPath($destinationPath); + + Filesystem::rename($sourcePath, $destinationPath); + + $this->markDirty($sourceDir); + $this->markDirty($destinationDir); + + } } |