Skip to content

Commit

Permalink
This is a shim to fix an upstream bug in Zenodo's API, reported in is…
Browse files Browse the repository at this point in the history
…sue #16.

There are no plans to push this change to crates.io, unless Zenodo refuses
to address the upstream issue.
  • Loading branch information
vsbuffalo committed Feb 23, 2024
1 parent ee21983 commit 63a5a20
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib/api/zenodo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,21 @@ pub struct ZenodoFileUpload {
delete_marker: bool,
}

// NOTE: this is a shim to address issue #16. This is caused by an upstream
// bug in Zenodo.
fn deserialize_filesize<'de, D>(deserializer: D) -> Result<usize, D::Error>
where
D: serde::Deserializer<'de>,
{
let filesize_float: f64 = serde::Deserialize::deserialize(deserializer)?;
Ok(filesize_float.trunc() as usize)
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ZenodoFile {
checksum: String,
filename: String,
#[serde(deserialize_with = "deserialize_filesize")]
filesize: usize,
id: String,
links: ZenodoLinks,
Expand Down

0 comments on commit 63a5a20

Please sign in to comment.