Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions wslplugins-rs/src/api/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ pub(crate) fn check_required_version_result(
}

pub(crate) fn check_required_version_result_from_context(
wsl_context: &WSLContext,
wsl_context: Option<&WSLContext>,
required_version: &WSLVersion,
) -> Result<()> {
let current_version = wsl_context.api.version();
check_required_version_result(current_version, required_version)
if let Some(context) = wsl_context {
let current_version = context.api.version();
check_required_version_result(current_version, required_version)
} else {
Ok(())
}
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions wslplugins-rs/src/distribution_information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ impl DistributionInformation<'_> {
/// # Returns
/// - `Ok(u32)`: The PID of the init process.
/// # Errors
/// [Error]: If the API version is insufficient.
/// [Error]: If the runtime version version is insufficient if no [WSLContext] found we assume returned value is accessible.
pub fn init_pid(&self) -> Result<u32> {
check_required_version_result_from_context(
WSLContext::get_current_or_panic(),
WSLContext::get_current(),
&WSLVersion::new(2, 0, 5),
)?;
Ok(self.0.InitPid)
Expand Down