diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-02-12 12:29:01 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-23 22:27:23 +0100 |
commit | 9f6dcb9d3e2f43f336dafeb739e04ba9614d9b5f (patch) | |
tree | fa72017a9bf76c526ddb3dfe0969f0584a4a7d67 /lib/private/connector/sabre/objecttree.php | |
parent | 66e3211fd8a57b0fb296d1dcc980272721e9f99d (diff) | |
download | nextcloud-server-9f6dcb9d3e2f43f336dafeb739e04ba9614d9b5f.tar.gz nextcloud-server-9f6dcb9d3e2f43f336dafeb739e04ba9614d9b5f.zip |
Sabre Update to 2.1
- VObject fixes for Sabre\VObject 3.3
- Remove VObject property workarounds
- Added prefetching for tags in sabre tags plugin
- Moved oc_properties logic to separate PropertyStorage backend (WIP)
- Fixed Sabre connector namespaces
- Improved files plugin to handle props on-demand
- Moved allowed props from server class to files plugin
- Fixed tags caching for files that are known to have no tags
(less queries)
- Added/fixed unit tests for Sabre FilesPlugin, TagsPlugin
- Replace OC\Connector\Sabre\Request with direct call to
httpRequest->setUrl()
- Fix exception detection in DAV client when using Sabre\DAV\Client
- Added setETag() on Node instead of using the static FileSystem
- Also preload tags/props when depth is infinity
Diffstat (limited to 'lib/private/connector/sabre/objecttree.php')
-rw-r--r-- | lib/private/connector/sabre/objecttree.php | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index 8793b612936..585be637813 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -30,7 +30,7 @@ use OC\Files\Mount\MoveableMount; use OCP\Files\StorageInvalidException; use OCP\Files\StorageNotAvailableException; -class ObjectTree extends \Sabre\DAV\ObjectTree { +class ObjectTree extends \Sabre\DAV\Tree { /** * @var \OC\Files\View @@ -44,8 +44,6 @@ class ObjectTree extends \Sabre\DAV\ObjectTree { /** * Creates the object - * - * This method expects the rootObject to be passed as a parameter */ public function __construct() { } @@ -62,6 +60,35 @@ class ObjectTree extends \Sabre\DAV\ObjectTree { } /** + * If the given path is a chunked file name, converts it + * to the real file name. Only applies if the OC-CHUNKED header + * is present. + * + * @param string $path chunk file path to convert + * + * @return string path to real file + */ + private function resolveChunkFile($path) { + if (isset($_SERVER['HTTP_OC_CHUNKED'])) { + // resolve to real file name to find the proper node + list($dir, $name) = \Sabre\HTTP\URLUtil::splitPath($path); + if ($dir == '/' || $dir == '.') { + $dir = ''; + } + + $info = \OC_FileChunking::decodeName($name); + // only replace path if it was really the chunked file + if (isset($info['transferid'])) { + // getNodePath is called for multiple nodes within a chunk + // upload call + $path = $dir . '/' . $info['name']; + $path = ltrim($path, '/'); + } + } + return $path; + } + + /** * Returns the INode object for the requested path * * @param string $path @@ -102,12 +129,15 @@ class ObjectTree extends \Sabre\DAV\ObjectTree { $info = null; } } else { + // resolve chunk file name to real name, if applicable + $path = $this->resolveChunkFile($path); + // read from cache try { $info = $this->fileView->getFileInfo($path); } catch (StorageNotAvailableException $e) { throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage not available'); - } catch (StorageInvalidException $e){ + } catch (StorageInvalidException $e) { throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid'); } } @@ -117,9 +147,9 @@ class ObjectTree extends \Sabre\DAV\ObjectTree { } if ($info->getType() === 'dir') { - $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); } $this->cache[$path] = $node; @@ -146,8 +176,8 @@ class ObjectTree extends \Sabre\DAV\ObjectTree { 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); + list($sourceDir,) = \Sabre\HTTP\URLUtil::splitPath($sourcePath); + list($destinationDir,) = \Sabre\HTTP\URLUtil::splitPath($destinationPath); $isMovableMount = false; $sourceMount = $this->mountManager->find($this->fileView->getAbsolutePath($sourcePath)); @@ -183,12 +213,6 @@ class ObjectTree extends \Sabre\DAV\ObjectTree { throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage()); } - // update properties - $query = \OC_DB::prepare('UPDATE `*PREFIX*properties` SET `propertypath` = ?' - . ' WHERE `userid` = ? AND `propertypath` = ?'); - $query->execute(array(\OC\Files\Filesystem::normalizePath($destinationPath), \OC_User::getUser(), - \OC\Files\Filesystem::normalizePath($sourcePath))); - $this->markDirty($sourceDir); $this->markDirty($destinationDir); @@ -229,7 +253,7 @@ class ObjectTree extends \Sabre\DAV\ObjectTree { throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage()); } - list($destinationDir,) = \Sabre\DAV\URLUtil::splitPath($destination); + list($destinationDir,) = \Sabre\HTTP\URLUtil::splitPath($destination); $this->markDirty($destinationDir); } } |