Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2017-03-29 12:16:41 +0300
committerJoas Schilling <coding@schilljs.com>2017-04-26 16:35:08 +0300
commit82b967d3f9f661b784f5ba97d5a69d0b40a1c7be (patch)
treebaabadaddd70f52701776a78df5644958af675c6 /apps/dav/lib/Connector/Sabre/ObjectTree.php
parent0a9f7730d0daeed565af28ad2e1528606bab6ba7 (diff)
Remove ObjectTree::move and let is use the IMoveTarget approach instead
This removes the duplicated code
Diffstat (limited to 'apps/dav/lib/Connector/Sabre/ObjectTree.php')
-rw-r--r--apps/dav/lib/Connector/Sabre/ObjectTree.php98
1 files changed, 0 insertions, 98 deletions
diff --git a/apps/dav/lib/Connector/Sabre/ObjectTree.php b/apps/dav/lib/Connector/Sabre/ObjectTree.php
index 554a7ad86ca..acc6dcc3be3 100644
--- a/apps/dav/lib/Connector/Sabre/ObjectTree.php
+++ b/apps/dav/lib/Connector/Sabre/ObjectTree.php
@@ -185,104 +185,6 @@ class ObjectTree extends \Sabre\DAV\Tree {
}
/**
- * 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 FileLocked
- * @throws Forbidden
- * @throws InvalidPath
- * @throws \Sabre\DAV\Exception\Forbidden
- * @throws \Sabre\DAV\Exception\Locked
- * @throws \Sabre\DAV\Exception\NotFound
- * @throws \Sabre\DAV\Exception\ServiceUnavailable
- * @return int
- */
- public function move($sourcePath, $destinationPath) {
- if (!$this->fileView) {
- throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
- }
-
- $infoDestination = $this->fileView->getFileInfo(dirname($destinationPath));
- if (dirname($destinationPath) === dirname($sourcePath)) {
- $sourcePermission = $infoDestination && $infoDestination->isUpdateable();
- $destinationPermission = $sourcePermission;
- } else {
- $infoSource = $this->fileView->getFileInfo($sourcePath);
- if ($this->fileView->file_exists($destinationPath)) {
- $destinationPermission = $infoDestination && $infoDestination->isUpdateable();
- } else {
- $destinationPermission = $infoDestination && $infoDestination->isCreatable();
- }
- $sourcePermission = $infoSource && $infoSource->isDeletable();
- }
-
- if (!$destinationPermission || !$sourcePermission) {
- throw new Forbidden('No permissions to move object.');
- }
-
- $targetNodeExists = $this->nodeExists($destinationPath);
- $sourceNode = $this->getNodeForPath($sourcePath);
- if ($sourceNode instanceof \Sabre\DAV\ICollection && $targetNodeExists) {
- throw new \Sabre\DAV\Exception\Forbidden('Could not copy directory ' . $sourceNode->getName() . ', target exists');
- }
- list($sourceDir,) = \Sabre\HTTP\URLUtil::splitPath($sourcePath);
- list($destinationDir,) = \Sabre\HTTP\URLUtil::splitPath($destinationPath);
-
- $isMovableMount = false;
- $sourceMount = $this->mountManager->find($this->fileView->getAbsolutePath($sourcePath));
- $internalPath = $sourceMount->getInternalPath($this->fileView->getAbsolutePath($sourcePath));
- if ($sourceMount instanceof MoveableMount && $internalPath === '') {
- $isMovableMount = true;
- }
-
- try {
- $sameFolder = ($sourceDir === $destinationDir);
- // if we're overwriting or same folder
- if ($targetNodeExists || $sameFolder) {
- // note that renaming a share mount point is always allowed
- if (!$this->fileView->isUpdatable($destinationDir) && !$isMovableMount) {
- throw new \Sabre\DAV\Exception\Forbidden();
- }
- } else {
- if (!$this->fileView->isCreatable($destinationDir)) {
- throw new \Sabre\DAV\Exception\Forbidden();
- }
- }
-
- if (!$sameFolder) {
- // moving to a different folder, source will be gone, like a deletion
- // note that moving a share mount point is always allowed
- if (!$this->fileView->isDeletable($sourcePath) && !$isMovableMount) {
- throw new \Sabre\DAV\Exception\Forbidden();
- }
- }
-
- $fileName = basename($destinationPath);
- try {
- $this->fileView->verifyPath($destinationDir, $fileName);
- } catch (\OCP\Files\InvalidPathException $ex) {
- throw new InvalidPath($ex->getMessage());
- }
-
- $renameOkay = $this->fileView->rename($sourcePath, $destinationPath);
- if (!$renameOkay) {
- throw new \Sabre\DAV\Exception\Forbidden('');
- }
- } catch (StorageNotAvailableException $e) {
- throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
- } catch (ForbiddenException $ex) {
- throw new Forbidden($ex->getMessage(), $ex->getRetry());
- } catch (LockedException $e) {
- throw new FileLocked($e->getMessage(), $e->getCode(), $e);
- }
-
- $this->markDirty($sourceDir);
- $this->markDirty($destinationDir);
-
- }
-
- /**
* Copies a file or directory.
*
* This method must work recursively and delete the destination