From de3e22e9f6814967a041849bea4ec6110eb3cec7 Mon Sep 17 00:00:00 2001 From: Vince Buffalo Date: Thu, 22 Feb 2024 16:47:51 -0800 Subject: [PATCH] This is a shim to fix an upstream bug in Zenodo's API, reported in issue #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. --- .gitignore | 1 + Cargo.toml | 2 +- src/lib/api/zenodo.rs | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5b878fa..e7eb7a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /tests/test_data/ +project_test/ diff --git a/Cargo.toml b/Cargo.toml index 826d5c1..6be681f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/lib/api/zenodo.rs b/src/lib/api/zenodo.rs index b725daf..358150f 100644 --- a/src/lib/api/zenodo.rs +++ b/src/lib/api/zenodo.rs @@ -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 +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,