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.

 - This converrts the float returned by Zenodo's API for `filesize` into a
   `usize` via serde. This change may be rolled back, if the Zenodo API
   changes back. However, this restores functionality in the meantime.
  • Loading branch information
vsbuffalo committed Feb 23, 2024
1 parent ee21983 commit de3e22e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/tests/test_data/
project_test/
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scidataflow"
version = "0.8.9"
version = "0.8.10"
edition = "2021"
exclude = ["logo.png", "tests/test_data/**"]
license = "MIT"
Expand Down
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 de3e22e

Please sign in to comment.