Repository: duckdb/duckdb
File: src/main/extension/extension_install.cpp (C++)

Code before:
#ifdef WASM_LOADABLE_EXTENSIONS
	// Install is currently a no-op
	return nullptr;
#endif
	auto &db = DatabaseInstance::GetDatabase(context);
	auto &fs = FileSystem::GetFileSystem(context);
	string local_path = ExtensionDirectory(context);
	return InstallExtensionInternal(db, fs, local_path, extension, options, context);
}

static unsafe_unique_array<data_t> ReadExtensionFileFromDisk(FileSystem &fs, const string &path, idx_t &file_size) {
	auto source_file = fs.OpenFile(path, FileFlags::FILE_FLAGS_READ);
	file_size = source_file->GetFileSize();
	auto in_buffer = make_unsafe_uniq_array<data_t>(file_size);
	source_file->Read(QueryContext(), in_buffer.get(), file_size);
	source_file->Close();
	return in_buffer;
}

static void WriteExtensionFileToDisk(QueryContext &query_context, FileSystem &fs, const string &path, void *data,
                                     idx_t data_size, DBConfig &config) {
	if (!config.options.allow_unsigned_extensions) {
		const bool signature_valid = ExtensionHelper::CheckExtensionBufferSignature(
		    (char *)data, data_size, config.options.allow_community_extensions);
		if (!signature_valid) {
			throw IOException("Attempting to install an extension file that hasn't a valid signature, see "
			                  "https://duckdb.org/docs/stable/operations_manual/securing_duckdb/securing_extensions");
		}
	}

	// Now signature has been checked (if signature checking is enabled)

	// Open target_file, at this points ending with '.duckdb_extension'
	auto target_file =
	    fs.OpenFile(path, FileFlags::FILE_FLAGS_WRITE | FileFlags::FILE_FLAGS_READ | FileFlags::FILE_FLAGS_APPEND |
	                          FileFlags::FILE_FLAGS_FILE_CREATE_NEW | FileFlags::FILE_FLAGS_ENABLE_EXTENSION_INSTALL);
	// Write content to the file
	target_file->Write(query_context, data, data_size);

	target_file->Close();
	target_file.reset();
}

static void WriteExtensionMetadataFileToDisk(FileSystem &fs, const string &path, ExtensionInstallInfo &metadata) {
	auto file_writer = BufferedFileWriter(fs, path);
	BinarySerializer::Serialize(metadata, file_writer);
	file_writer.Sync();
}

string ExtensionHelper::ExtensionUrlTemplate(optional_ptr<const DatabaseInstance> db,
                                             const ExtensionRepository &repository, const string &version) {

Review comment (suggestion):
```suggestion
			throw IOException("Attempting to install an extension file that doesn't have a valid signature, see "
```

Code after:
#ifdef WASM_LOADABLE_EXTENSIONS
	// Install is currently a no-op
	return nullptr;
#endif
	auto &db = DatabaseInstance::GetDatabase(context);
	auto &fs = FileSystem::GetFileSystem(context);
	string local_path = ExtensionDirectory(context);
	return InstallExtensionInternal(db, fs, local_path, extension, options, context);
}

static unsafe_unique_array<data_t> ReadExtensionFileFromDisk(FileSystem &fs, const string &path, idx_t &file_size) {
	auto source_file = fs.OpenFile(path, FileFlags::FILE_FLAGS_READ);
	file_size = source_file->GetFileSize();
	auto in_buffer = make_unsafe_uniq_array<data_t>(file_size);
	source_file->Read(QueryContext(), in_buffer.get(), file_size);
	source_file->Close();
	return in_buffer;
}

static void WriteExtensionFileToDisk(QueryContext &query_context, FileSystem &fs, const string &path, void *data,
                                     idx_t data_size, DBConfig &config) {
	if (!config.options.allow_unsigned_extensions) {
		const bool signature_valid = ExtensionHelper::CheckExtensionBufferSignature(
		    static_cast<char *>(data), data_size, config.options.allow_community_extensions);
		if (!signature_valid) {
			throw IOException("Attempting to install an extension file that doesn't have a valid signature, see "
			                  "https://duckdb.org/docs/stable/operations_manual/securing_duckdb/securing_extensions");
		}
	}

	// Now signature has been checked (if signature checking is enabled)

	// Open target_file, at this points ending with '.duckdb_extension'
	auto target_file =
	    fs.OpenFile(path, FileFlags::FILE_FLAGS_WRITE | FileFlags::FILE_FLAGS_READ | FileFlags::FILE_FLAGS_APPEND |
	                          FileFlags::FILE_FLAGS_FILE_CREATE_NEW | FileFlags::FILE_FLAGS_ENABLE_EXTENSION_INSTALL);
	// Write content to the file
	target_file->Write(query_context, data, data_size);

	target_file->Close();
	target_file.reset();
}

static void WriteExtensionMetadataFileToDisk(FileSystem &fs, const string &path, ExtensionInstallInfo &metadata) {
	auto file_writer = BufferedFileWriter(fs, path);
	BinarySerializer::Serialize(metadata, file_writer);
	file_writer.Sync();
}

string ExtensionHelper::ExtensionUrlTemplate(optional_ptr<const DatabaseInstance> db,
                                             const ExtensionRepository &repository, const string &version) {