Skip to content

Commit

Permalink
Merge pull request #17 from vsbuffalo/zenodo-shim
Browse files Browse the repository at this point in the history
This is a shim to fix an upstream issue in Zenodo's API
  • Loading branch information
vsbuffalo authored Feb 23, 2024
2 parents ee21983 + de3e22e commit d12482c
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 d12482c

Please sign in to comment.