Skip to content

fix(list): panic when creation_date_utc is null #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,11 @@ pub struct ListItem {
/// Size of the file in bytes.
pub file_size: u64,
/// ISO8601 formatted date-time string of the creation timestamp.
#[serde(default = "creation_date_utc_default")]
pub creation_date_utc: String,
pub creation_date_utc: Option<String>,
/// ISO8601 formatted date-time string of the expiration timestamp if one exists for this file.
pub expires_at_utc: Option<String>,
}

fn creation_date_utc_default() -> String {
"info not available".to_string()
}

/// Wrapper around raw data and result.
#[derive(Debug)]
pub struct UploadResult<'a, T>(pub &'a str, pub Result<T>);
Expand Down Expand Up @@ -328,12 +323,11 @@ impl<'a> Uploader<'a> {
"{:<filename_width$} | {:>filesize_width$} | {:<19} | {}",
file_info.file_name,
file_info.file_size,
file_info.creation_date_utc,
file_info
.expires_at_utc
.as_ref()
.cloned()
.unwrap_or_default()
.creation_date_utc
.as_deref()
.unwrap_or("info not available"),
file_info.expires_at_utc.as_deref().unwrap_or_default()
)
})?;
Ok(())
Expand Down
Loading