Skip to content

Commit

Permalink
skip serializing 'yanked' bool if false
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Jun 18, 2020
1 parent ff26cc3 commit 9644520
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ pub(crate) async fn put(mut req: Request<State>) -> Result<Response, Error> {
.collect(),
cksum: hash,
features: metadata.features,
yanked: Some(false),
yanked: false,
links: metadata.links,
};

Expand Down
4 changes: 2 additions & 2 deletions src/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ pub trait Indexer {
F: FnOnce(&mut CrateVersion);
/// Yanks a crate version.
fn yank_record(&self, name: &str, version: Version) -> Result<(), Error> {
self.alter_record(name, version, |krate| krate.yanked = Some(true))
self.alter_record(name, version, |krate| krate.yanked = true)
}
/// Un-yanks a crate version.
fn unyank_record(&self, name: &str, version: Version) -> Result<(), Error> {
self.alter_record(name, version, |krate| krate.yanked = Some(false))
self.alter_record(name, version, |krate| krate.yanked = false)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/index/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub struct CrateVersion {
pub features: HashMap<String, Vec<String>>,

/// Is the crate yanked.
pub yanked: Option<bool>,
#[serde(skip_serializing_if = "std::ops::Not::not", default)]
pub yanked: bool,

/// Is the crate yanked.
#[serde(skip_serializing_if = "Option::is_none", default)]
Expand Down

0 comments on commit 9644520

Please sign in to comment.