[Pkg-owncloud-commits] [php-sabredav] 03/05: Updates Issue 40
David Prévot
taffit at moszumanska.debian.org
Sat Nov 30 15:44:06 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag version-1.0.13
in repository php-sabredav.
commit 394c8d3ca3bbe627a0ad0653fc446ca9fafa056f
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Tue Mar 30 17:36:06 2010 +0900
Updates Issue 40
Removing last references to basename/dirname
---
lib/Sabre/DAV/FS/Node.php | 11 +++++++++--
lib/Sabre/DAV/FSExt/Node.php | 14 +++++++++++---
lib/Sabre/DAV/Server.php | 5 ++---
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/lib/Sabre/DAV/FS/Node.php b/lib/Sabre/DAV/FS/Node.php
index 40fe860..7117c65 100644
--- a/lib/Sabre/DAV/FS/Node.php
+++ b/lib/Sabre/DAV/FS/Node.php
@@ -42,7 +42,8 @@ abstract class Sabre_DAV_FS_Node implements Sabre_DAV_INode {
*/
public function getName() {
- return basename($this->path);
+ list(, $name) = Sabre_DAV_URLUtil::splitPath($this->path);
+ return $name;
}
@@ -54,7 +55,13 @@ abstract class Sabre_DAV_FS_Node implements Sabre_DAV_INode {
*/
public function setName($name) {
- rename($this->path,dirname($this->path) . '/' . basename($name));
+ list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path);
+ list(, $newName) = Sabre_DAV_URLUtil::splitPath($name);
+
+ $newPath = $parentPath . '/' . $newName;
+ rename($this->path,$newPath);
+
+ $this->path = $newPath;
}
diff --git a/lib/Sabre/DAV/FSExt/Node.php b/lib/Sabre/DAV/FSExt/Node.php
index 869892c..746899c 100644
--- a/lib/Sabre/DAV/FSExt/Node.php
+++ b/lib/Sabre/DAV/FSExt/Node.php
@@ -161,7 +161,8 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
*/
protected function getResourceInfoPath() {
- return dirname($this->path) . '/.sabredav';
+ list($parentDir) = Sabre_DAV_URLUtil::splitPath($this->path);
+ return $parentDir . '/.sabredav';
}
@@ -242,10 +243,17 @@ abstract class Sabre_DAV_FSExt_Node extends Sabre_DAV_FS_Node implements Sabre_D
*/
public function setName($name) {
+ list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path);
+ list(, $newName) = Sabre_DAV_URLUtil::splitPath($name);
+ $newPath = $parentPath . '/' . $newName;
+
+ // We're deleting the existing resourcedata, and recreating it
+ // for the new path.
$resourceData = $this->getResourceData();
$this->deleteResourceData();
- rename($this->path,dirname($this->path) . '/' . basename($name));
- $this->path = dirname($this->path) .'/' . basename($name);
+
+ rename($this->path,$newPath);
+ $this->path = $newPath;
$this->putResourceData($resourceData);
diff --git a/lib/Sabre/DAV/Server.php b/lib/Sabre/DAV/Server.php
index a30c878..5a8ff31 100644
--- a/lib/Sabre/DAV/Server.php
+++ b/lib/Sabre/DAV/Server.php
@@ -849,14 +849,13 @@ class Sabre_DAV_Server {
// We need to throw a bad request exception, if the header was invalid
else throw new Sabre_DAV_Exception_BadRequest('The HTTP Overwrite header should be either T or F');
- $destinationUri = dirname($destination);
- if ($destinationUri=='.') $destinationUri='';
+ list($destinationDir) = Sabre_DAV_URLUtil::splitPath($destination);
// Collection information on relevant existing nodes
$sourceNode = $this->tree->getNodeForPath($source);
try {
- $destinationParent = $this->tree->getNodeForPath($destinationUri);
+ $destinationParent = $this->tree->getNodeForPath($destinationDir);
if (!($destinationParent instanceof Sabre_DAV_ICollection)) throw new Sabre_DAV_Exception_UnsupportedMediaType('The destination node is not a collection');
} catch (Sabre_DAV_Exception_FileNotFound $e) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list