protected function flushWrites()
    {
        if ( ! $this->queuedForWrite) {
            return;
        }

        $target = $this->getOrMakeTargetInstance();

        $storedFiles = $this->handler->process($this->uploadedFile, $target, $this->config->toArray());

        if ($this->shouldVariantInformationBeStored()) {

            $originalExtension  = pathinfo($this->originalFilename(), PATHINFO_EXTENSION);
            $originalMimeType   = $this->contentType();
            $variantInformation = [];

            foreach ($storedFiles as $variant => $storedFile) {
                if (    $storedFile->extension() == $originalExtension
                    &&  $storedFile->mimeType() == $originalMimeType
                ) {
                    continue;
                }

                $variantInformation[ $variant ] = [
                    'ext'  => $storedFile->extension(),
                    'type' => $storedFile->mimeType(),
                ];
            }

            $this->instanceWrite('variants', json_encode($variantInformation));
            $this->instance->save();
        }

        $this->queuedForWrite = false;
    }