From d2d2c9a46d86be2b38d6e88c1943e7328ebb26d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas.mueller@tmit.eu>
Date: Thu, 17 Oct 2013 20:20:13 +0200
Subject: [PATCH] fixes #5367

---
 lib/private/connector/sabre/file.php |  2 +-
 lib/private/filechunking.php         | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 3402946a13..fd12039d91 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -215,7 +215,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
 			if (isset($_SERVER['CONTENT_LENGTH'])) {
 				$expected = $_SERVER['CONTENT_LENGTH'];
 				if ($bytesWritten != $expected) {
-					$chunk_handler->cleanup();
+					$chunk_handler->remove($info['index']);
 					throw new Sabre_DAV_Exception_BadRequest(
 						'expected filesize ' . $expected . ' got ' . $bytesWritten);
 				}
diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php
index 0dfce696cd..aa4f73c7c0 100644
--- a/lib/private/filechunking.php
+++ b/lib/private/filechunking.php
@@ -85,6 +85,16 @@ class OC_FileChunking {
 		}
 	}
 
+	/**
+	 * Removes one specific chunk
+	 * @param $index
+	 */
+	public function remove($index) {
+		$cache = $this->getCache();
+		$prefix = $this->getPrefix();
+		$cache->remove($prefix.$index);
+	}
+
 	public function signature_split($orgfile, $input) {
 		$info = unpack('n', fread($input, 2));
 		$blocksize = $info[1];
-- 
GitLab