summaryrefslogtreecommitdiffstats
path: root/lib/private/connector/sabre/objecttree.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/connector/sabre/objecttree.php')
-rw-r--r--lib/private/connector/sabre/objecttree.php54
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);
}
}