diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-02-23 16:19:23 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-03-07 19:52:30 +0100 |
commit | e08f98075cff2087daba94cce1fb7e48e9d3c3ad (patch) | |
tree | 95c405d15a17a9bd8d10cddc1355cba0db58d29d /lib/private/filechunking.php | |
parent | 0487b541a016be8be24114d494f9abc752abd748 (diff) | |
download | nextcloud-server-e08f98075cff2087daba94cce1fb7e48e9d3c3ad.tar.gz nextcloud-server-e08f98075cff2087daba94cce1fb7e48e9d3c3ad.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/private/filechunking.php')
-rw-r--r-- | lib/private/filechunking.php | 12 |
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; } /** |