summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-02-23 16:19:23 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2016-03-09 14:48:31 +0100
commit313b881d2b38f4a0ed43afc68dafacd65524b0b7 (patch)
tree81988e34f42af3c6634fcc83fdd0d3b2e78bf086 /lib
parentd4d4b8d51a38e7b7ad2ec983ca090db0a0466a92 (diff)
downloadnextcloud-server-313b881d2b38f4a0ed43afc68dafacd65524b0b7.tar.gz
nextcloud-server-313b881d2b38f4a0ed43afc68dafacd65524b0b7.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/filechunking.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php
index ece215e7344..32cbb7559f0 100644
--- a/lib/private/filechunking.php
+++ b/lib/private/filechunking.php
@@ -74,14 +74,16 @@ class OC_FileChunking {
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;
}
/**