summaryrefslogtreecommitdiffstats
path: root/lib/private/connector/sabre/directory.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/connector/sabre/directory.php')
-rw-r--r--lib/private/connector/sabre/directory.php83
1 files changed, 15 insertions, 68 deletions
diff --git a/lib/private/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php
index 682fd62ee37..f13a0d7bbd8 100644
--- a/lib/private/connector/sabre/directory.php
+++ b/lib/private/connector/sabre/directory.php
@@ -1,4 +1,6 @@
<?php
+namespace OC\Connector\Sabre;
+
/**
* @author Arthur Schiwon <blizzz@owncloud.com>
* @author Bart Visscher <bartv@thisnet.nl>
@@ -24,7 +26,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
+class Directory extends \OC\Connector\Sabre\Node
implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota {
/**
@@ -74,7 +76,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
// exit if we can't create a new file and we don't updatable existing file
- $info = OC_FileChunking::decodeName($name);
+ $info = \OC_FileChunking::decodeName($name);
if (!$this->fileView->isCreatable($this->path) &&
!$this->fileView->isUpdatable($this->path . '/' . $info['name'])
) {
@@ -91,7 +93,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
$path = $this->fileView->getAbsolutePath($this->path) . '/' . $name;
// 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(), null);
- $node = new OC_Connector_Sabre_File($this->fileView, $info);
+ $node = new \OC\Connector\Sabre\File($this->fileView, $info);
return $node->put($data);
} catch (\OCP\Files\StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
@@ -143,9 +145,9 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
}
if ($info['mimetype'] == 'httpd/unix-directory') {
- $node = new OC_Connector_Sabre_Directory($this->fileView, $info);
+ $node = new \OC\Connector\Sabre\Directory($this->fileView, $info);
} else {
- $node = new OC_Connector_Sabre_File($this->fileView, $info);
+ $node = new \OC\Connector\Sabre\File($this->fileView, $info);
}
return $node;
}
@@ -161,42 +163,9 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
}
$folderContent = $this->fileView->getDirectoryContent($this->path);
- $properties = array();
- $paths = array();
- foreach ($folderContent as $info) {
- $name = $info->getName();
- $paths[] = $this->path . '/' . $name;
- $properties[$this->path . '/' . $name][self::GETETAG_PROPERTYNAME] = '"' . $info->getEtag() . '"';
- }
- // TODO: move this to a beforeGetPropertiesForPath event to pre-cache properties
- // TODO: only fetch the requested properties
- if (count($paths) > 0) {
- //
- // the number of arguments within IN conditions are limited in most databases
- // we chunk $paths into arrays of 200 items each to meet this criteria
- //
- $chunks = array_chunk($paths, 200, false);
- foreach ($chunks as $pack) {
- $placeholders = join(',', array_fill(0, count($pack), '?'));
- $query = OC_DB::prepare('SELECT * FROM `*PREFIX*properties`'
- . ' WHERE `userid` = ?' . ' AND `propertypath` IN (' . $placeholders . ')');
- array_unshift($pack, OC_User::getUser()); // prepend userid
- $result = $query->execute($pack);
- while ($row = $result->fetchRow()) {
- $propertypath = $row['propertypath'];
- $propertyname = $row['propertyname'];
- $propertyvalue = $row['propertyvalue'];
- if ($propertyname !== self::GETETAG_PROPERTYNAME) {
- $properties[$propertypath][$propertyname] = $propertyvalue;
- }
- }
- }
- }
-
$nodes = array();
foreach ($folderContent as $info) {
$node = $this->getChild($info->getName(), $info);
- $node->setPropertyCache($properties[$this->path . '/' . $info->getName()]);
$nodes[] = $node;
}
$this->dirContent = $nodes;
@@ -210,7 +179,13 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
* @return bool
*/
public function childExists($name) {
-
+ // note: here we do NOT resolve the chunk file name to the real file name
+ // to make sure we return false when checking for file existence with a chunk
+ // file name.
+ // This is to make sure that "createFile" is still triggered
+ // (required old code) instead of "updateFile".
+ //
+ // TODO: resolve chunk file name here and implement "updateFile"
$path = $this->path . '/' . $name;
return $this->fileView->file_exists($path);
@@ -245,7 +220,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
return $this->quotaInfo;
}
try {
- $storageInfo = OC_Helper::getStorageInfo($this->info->getPath(), $this->info);
+ $storageInfo = \OC_Helper::getStorageInfo($this->info->getPath(), $this->info);
$this->quotaInfo = array(
$storageInfo['used'],
$storageInfo['free']
@@ -256,32 +231,4 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
}
}
- /**
- * Returns a list of properties for this nodes.;
- *
- * The properties list is a list of propertynames the client requested,
- * encoded as xmlnamespace#tagName, for example:
- * http://www.example.org/namespace#author
- * If the array is empty, all properties should be returned
- *
- * @param array $properties
- * @return array
- */
- 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->info->getEtag();
- }
- return $props;
- }
-
- /**
- * Returns the size of the node, in bytes
- *
- * @return int
- */
- public function getSize() {
- return $this->info->getSize();
- }
-
}