fix: make optional inputs actually optional.

This commit is contained in:
redxef 2024-10-30 01:22:40 +01:00
parent 3759b37351
commit 1c60d426c9
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
2 changed files with 13 additions and 8 deletions

View file

@ -170,11 +170,13 @@ async fn in_(input: model::InInput, dest: &Path) -> Result<model::InOutput> {
}, },
metadata: vec![], metadata: vec![],
}; };
if out.version != input.version { if let Some(input_version) = &input.version {
return Err(anyhow!(format!( if out.version != *input_version {
"Did not get correct version of resource, requested '{:?}', got '{:?}'", return Err(anyhow!(format!(
input.version, out.version "Did not get correct version of resource, requested '{:?}', got '{:?}'",
))); input.version, out.version
)));
}
} }
Ok(out) Ok(out)
} }
@ -189,7 +191,7 @@ async fn out(input: model::OutInput, src: &Path) -> Result<model::OutOutput> {
response.error_for_status()?; response.error_for_status()?;
let version = check(model::CheckInput { let version = check(model::CheckInput {
source: input.source.clone(), source: input.source.clone(),
version: model::Version::None, version: None,
}) })
.await? .await?
.0[0] .0[0]

View file

@ -150,19 +150,22 @@ pub struct Params {
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct CheckInput { pub struct CheckInput {
pub source: Source, pub source: Source,
pub version: Version, #[serde(default)]
pub version: Option<Version>,
} }
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct InInput { pub struct InInput {
pub source: Source, pub source: Source,
pub version: Version, pub version: Option<Version>,
#[serde(default)]
pub params: Params, pub params: Params,
} }
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct OutInput { pub struct OutInput {
pub source: Source, pub source: Source,
#[serde(default)]
pub params: Params, pub params: Params,
} }