Phalcon\Db\Adapter\MongoDB\GridFS\Exception\CorruptFileException::missingChunk PHP Method

missingChunk() public static method

Thrown when a chunk is not found for an expected index.
public static missingChunk ( integer $expectedIndex ) : self
$expectedIndex integer Expected index number
return self
    public static function missingChunk($expectedIndex)
    {
        return new static(sprintf('Chunk not found for index "%d"', $expectedIndex));
    }

Usage Example

Beispiel #1
0
 private function advanceChunks()
 {
     if ($this->chunkOffset >= $this->numChunks) {
         $this->iteratorEmpty = true;
         return false;
     }
     if ($this->firstCheck) {
         $this->chunksIterator->rewind();
         $this->firstCheck = false;
     } else {
         $this->chunksIterator->next();
     }
     if (!$this->chunksIterator->valid()) {
         throw CorruptFileException::missingChunk($this->chunkOffset);
     }
     if ($this->chunksIterator->current()->n != $this->chunkOffset) {
         throw CorruptFileException::unexpectedIndex($this->chunksIterator->current()->n, $this->chunkOffset);
     }
     $actualChunkSize = strlen($this->chunksIterator->current()->data->getData());
     $expectedChunkSize = $this->chunkOffset == $this->numChunks - 1 ? $this->file->length - $this->bytesSeen : $this->file->chunkSize;
     if ($actualChunkSize != $expectedChunkSize) {
         throw CorruptFileException::unexpectedSize($actualChunkSize, $expectedChunkSize);
     }
     $this->bytesSeen += $actualChunkSize;
     $this->chunkOffset++;
     return true;
 }