fix: make optional inputs actually optional.
This commit is contained in:
parent
3759b37351
commit
1c60d426c9
2 changed files with 13 additions and 8 deletions
14
src/main.rs
14
src/main.rs
|
@ -170,11 +170,13 @@ async fn in_(input: model::InInput, dest: &Path) -> Result<model::InOutput> {
|
|||
},
|
||||
metadata: vec![],
|
||||
};
|
||||
if out.version != input.version {
|
||||
return Err(anyhow!(format!(
|
||||
"Did not get correct version of resource, requested '{:?}', got '{:?}'",
|
||||
input.version, out.version
|
||||
)));
|
||||
if let Some(input_version) = &input.version {
|
||||
if out.version != *input_version {
|
||||
return Err(anyhow!(format!(
|
||||
"Did not get correct version of resource, requested '{:?}', got '{:?}'",
|
||||
input.version, out.version
|
||||
)));
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
@ -189,7 +191,7 @@ async fn out(input: model::OutInput, src: &Path) -> Result<model::OutOutput> {
|
|||
response.error_for_status()?;
|
||||
let version = check(model::CheckInput {
|
||||
source: input.source.clone(),
|
||||
version: model::Version::None,
|
||||
version: None,
|
||||
})
|
||||
.await?
|
||||
.0[0]
|
||||
|
|
|
@ -150,19 +150,22 @@ pub struct Params {
|
|||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CheckInput {
|
||||
pub source: Source,
|
||||
pub version: Version,
|
||||
#[serde(default)]
|
||||
pub version: Option<Version>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct InInput {
|
||||
pub source: Source,
|
||||
pub version: Version,
|
||||
pub version: Option<Version>,
|
||||
#[serde(default)]
|
||||
pub params: Params,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct OutInput {
|
||||
pub source: Source,
|
||||
#[serde(default)]
|
||||
pub params: Params,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue