Skip to content

Commit

Permalink
Do not check all chunks of a chunked upload if we do not need to
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rullzer committed Mar 7, 2016
1 parent 0487b54 commit e08f980
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/private/filechunking.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,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;
}

/**
Expand Down

0 comments on commit e08f980

Please sign in to comment.