private function handleDuplicate(Media $model)
    {
        if ($this->filesystem->disk($model->disk)->has($model->getDiskPath())) {
            switch ($this->config['on_duplicate']) {
                case static::ON_DUPLICATE_ERROR:
                    throw FileExistsException::fileExists($model->getDiskPath());
                    break;
                case static::ON_DUPLICATE_REPLACE:
                    $this->deleteExistingMedia($model);
                    break;
                case static::ON_DUPLICATE_UPDATE:
                    $this->deleteExistingFile($model);
                    $model->{$model->getKeyName()} = Media::forPathOnDisk(
                        $model->disk, $model->getDiskPath())
                        ->pluck($model->getKeyName())->first();
                    $model->exists = true;
                    break;
                case static::ON_DUPLICATE_INCREMENT:
                default:
                    $model->filename = $this->generateUniqueFilename($model);
            }
        }
        return $model;
    }