Handle null value for size_in_bytes in API files
This commit is contained in:
parent
4612ffc3c4
commit
ced31f0eb6
@ -88,10 +88,19 @@ impl FilesResponse {
|
|||||||
let size = file
|
let size = file
|
||||||
.get("size_in_bytes")
|
.get("size_in_bytes")
|
||||||
.ok_or_else(|| anyhow!("Missing size_in_bytes key in file in API response"))?
|
.ok_or_else(|| anyhow!("Missing size_in_bytes key in file in API response"))?
|
||||||
.as_i64()
|
.as_i64();
|
||||||
.ok_or_else(|| {
|
let size = if let Some(size) = size {
|
||||||
anyhow!("size_in_bytes value in API response file is not a number")
|
size
|
||||||
})?;
|
} else {
|
||||||
|
file
|
||||||
|
.get("size_kb")
|
||||||
|
.ok_or_else(|| anyhow!("Missing size_kb key in file in API response"))?
|
||||||
|
.as_i64()
|
||||||
|
.ok_or_else(|| {
|
||||||
|
anyhow!("size_in_bytes and size_kb values in API response file are not numbers")
|
||||||
|
})? * 1000
|
||||||
|
};
|
||||||
|
|
||||||
let uploaded_timestamp = file
|
let uploaded_timestamp = file
|
||||||
.get("uploaded_timestamp")
|
.get("uploaded_timestamp")
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
|
Loading…
Reference in New Issue
Block a user