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.
This commit is contained in:
Roeland Jago Douma 2016-02-23 16:19:23 +01:00
parent d4d4b8d51a
commit 313b881d2b
1 changed files with 7 additions and 5 deletions

View File

@ -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;
}
/**