From 4d353ef249131e000f1b168ad344ea1d28fbc506 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 23 Feb 2016 16:19:23 +0100 Subject: [PATCH] Do not check all chunks of a chunked upload if we do not need to Fixes #22601 Before we did a full test on all chunks to verify if a chunked upload was completed. This is unneeded since if we are missing one chunk we can already fail. Also we look from back to front since it is much more likely that we find a missing chunk thus can error out early. --- lib/private/filechunking.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php index 8c341df4a8be..7b88bfecd19d 100644 --- a/lib/private/filechunking.php +++ b/lib/private/filechunking.php @@ -75,14 +75,16 @@ public function store($index, $data) { public function isComplete() { $prefix = $this->getPrefix(); - $parts = 0; $cache = $this->getCache(); - for($i=0; $i < $this->info['chunkcount']; $i++) { - if ($cache->hasKey($prefix.$i)) { - $parts ++; + $chunkcount = (int)$this->info['chunkcount']; + + for($i=($chunkcount-1); $i >= 0; $i--) { + if (!$cache->hasKey($prefix.$i)) { + return false; } } - return $parts == $this->info['chunkcount']; + + return true; } /**