diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-02-25 16:23:09 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-02-25 16:23:09 +0100 |
commit | 3a21755963d8d9897a48ab58292345c0b710e239 (patch) | |
tree | f6b8fd3065a03f2c5627b4f0d89c4b51d69c5c42 /lib/private/connector/sabre/directory.php | |
parent | 9b4af31bac977cb788a6f4a013d32ba0a21437f0 (diff) | |
download | nextcloud-server-3a21755963d8d9897a48ab58292345c0b710e239.tar.gz nextcloud-server-3a21755963d8d9897a48ab58292345c0b710e239.zip |
Pass the filesystem view as argument in the sabredav connectors and use the fileinfo object
Diffstat (limited to 'lib/private/connector/sabre/directory.php')
-rw-r--r-- | lib/private/connector/sabre/directory.php | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/private/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php index 02d1a9f4ba2..619aec21eac 100644 --- a/lib/private/connector/sabre/directory.php +++ b/lib/private/connector/sabre/directory.php @@ -60,20 +60,22 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa // exit if we can't create a new file and we don't updatable existing file $info = OC_FileChunking::decodeName($name); - if (!\OC\Files\Filesystem::isCreatable($this->path) && - !\OC\Files\Filesystem::isUpdatable($this->path . '/' . $info['name'])) { + if (!$this->fileView->isCreatable($this->path) && + !$this->fileView->isUpdatable($this->path . '/' . $info['name'])) { throw new \Sabre_DAV_Exception_Forbidden(); } } else { // For non-chunked upload it is enough to check if we can create a new file - if (!\OC\Files\Filesystem::isCreatable($this->path)) { + if (!$this->fileView->isCreatable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } } $path = $this->path . '/' . $name; - $node = new OC_Connector_Sabre_File($path); + // using a dummy FileInfo is acceptable here since it will be refreshed after the put is complete + $info = new \OC\Files\FileInfo($path, null, null, array()); + $node = new OC_Connector_Sabre_File($this->fileView, $info); return $node->put($data); } @@ -90,12 +92,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa throw new \Sabre_DAV_Exception_Forbidden(); } - if (!\OC\Files\Filesystem::isCreatable($this->path)) { + if (!$this->fileView->isCreatable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } $newPath = $this->path . '/' . $name; - if(!\OC\Files\Filesystem::mkdir($newPath)) { + if(!$this->fileView->mkdir($newPath)) { throw new Sabre_DAV_Exception_Forbidden('Could not create directory '.$newPath); } @@ -105,6 +107,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa * Returns a specific child node, referenced by its name * * @param string $name + * @param \OCP\Files\FileInfo $info * @throws Sabre_DAV_Exception_FileNotFound * @return Sabre_DAV_INode */ @@ -112,7 +115,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $path = $this->path . '/' . $name; if (is_null($info)) { - $info = \OC\Files\Filesystem::getFileInfo($path); + $info = $this->fileView->getFileInfo($path); } if (!$info) { @@ -120,12 +123,10 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa } if ($info['mimetype'] == 'httpd/unix-directory') { - $node = new OC_Connector_Sabre_Directory($path); + $node = new OC_Connector_Sabre_Directory($this->fileView, $info); } else { - $node = new OC_Connector_Sabre_File($path); + $node = new OC_Connector_Sabre_File($this->fileView, $info); } - - $node->setFileinfoCache($info); return $node; } @@ -136,7 +137,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa */ public function getChildren() { - $folder_content = \OC\Files\Filesystem::getDirectoryContent($this->path); + $folder_content = $this->fileView->getDirectoryContent($this->path); $paths = array(); foreach($folder_content as $info) { $paths[] = $this->path.'/'.$info['name']; @@ -167,7 +168,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $nodes = array(); foreach($folder_content as $info) { - $node = $this->getChild($info['name'], $info); + $node = $this->getChild($info->getName(), $info); $node->setPropertyCache($properties[$this->path.'/'.$info['name']]); $nodes[] = $node; } @@ -183,7 +184,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa public function childExists($name) { $path = $this->path . '/' . $name; - return \OC\Files\Filesystem::file_exists($path); + return $this->fileView->file_exists($path); } @@ -199,11 +200,11 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa throw new \Sabre_DAV_Exception_Forbidden(); } - if (!\OC\Files\Filesystem::isDeletable($this->path)) { + if (!$this->info->isDeletable()) { throw new \Sabre_DAV_Exception_Forbidden(); } - \OC\Files\Filesystem::rmdir($this->path); + $this->fileView->rmdir($this->path); } @@ -235,7 +236,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa public function getProperties($properties) { $props = parent::getProperties($properties); if (in_array(self::GETETAG_PROPERTYNAME, $properties) && !isset($props[self::GETETAG_PROPERTYNAME])) { - $props[self::GETETAG_PROPERTYNAME] = $this->getETagPropertyForPath($this->path); + $props[self::GETETAG_PROPERTYNAME] = $this->info->getEtag(); } return $props; } |