From 31149fb1c3591d968c38a256f54b32fa22222247 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas.mueller@tmit.eu>
Date: Tue, 22 Jul 2014 13:06:20 +0200
Subject: [PATCH] adding special handling of checkPrecondition() for chunked
 upload

---
 lib/private/connector/sabre/server.php | 31 ++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/lib/private/connector/sabre/server.php b/lib/private/connector/sabre/server.php
index e4ee5dcefb..aaf4fe85af 100644
--- a/lib/private/connector/sabre/server.php
+++ b/lib/private/connector/sabre/server.php
@@ -28,6 +28,37 @@
  */
 class OC_Connector_Sabre_Server extends Sabre\DAV\Server {
 
+	/**
+	 * @var string
+	 */
+	private $overLoadedUri = null;
+
+	public function getRequestUri() {
+
+		if (!is_null($this->overLoadedUri)) {
+			return $this->overLoadedUri;
+		}
+
+		return parent::getRequestUri();
+	}
+
+	public function checkPreconditions($handleAsGET = false) {
+		// chunked upload handling
+		if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
+			$filePath = parent::getRequestUri();
+			list($path, $name) = \Sabre\DAV\URLUtil::splitPath($filePath);
+			$info = OC_FileChunking::decodeName($name);
+			if (!empty($info)) {
+				$filePath = $path . '/' . $info['name'];
+				$this->overLoadedUri = $filePath;
+			}
+		}
+
+		$result = parent::checkPreconditions($handleAsGET);
+		$this->overLoadedUri = null;
+		return $result;
+	}
+
 	/**
 	 * @see \Sabre\DAV\Server
 	 */
-- 
GitLab