Refactor whitespace handling in JSON serialization and improve ISO-8601 timestamp formatting

- Removed unnecessary spaces in JSON key-value and array formatting for Python-style compatibility.
- Enhanced `format_iso8601_basic` to ensure precise microsecond-level time formatting.
- Updated `write_update_log` to return and store SHA-1 signatures for update log verification.
This commit is contained in:
Till Wegmueller 2025-12-23 12:33:12 +01:00
parent ff0b9f4319
commit b32ace705f
No known key found for this signature in database
4 changed files with 7 additions and 8 deletions

View file

@ -1,2 +0,0 @@
language = "rust"
run = "cargo test"

View file

@ -66,7 +66,8 @@ pub type Result<T> = std::result::Result<T, CatalogError>;
/// Format a SystemTime as an ISO-8601 'basic format' date in UTC
pub fn format_iso8601_basic(time: &SystemTime) -> String {
let datetime = convert_system_time_to_datetime(time);
format!("{}Z", datetime.format("%Y%m%dT%H%M%S.%f"))
let micros = datetime.timestamp_subsec_micros();
format!("{}.{:06}Z", datetime.format("%Y%m%dT%H%M%S"), micros)
}
/// Convert SystemTime to UTC DateTime, handling errors gracefully

View file

@ -2520,7 +2520,7 @@ impl FileBackend {
);
}
let _ = catalog_writer::write_update_log(&update_log_path, &mut update_log)?;
let update_log_sig = catalog_writer::write_update_log(&update_log_path, &mut update_log)?;
debug!("Wrote update log file");
// Add an update log to catalog.attrs
@ -2529,7 +2529,7 @@ impl FileBackend {
update_log_name.clone(),
crate::repository::catalog::UpdateLogInfo {
last_modified: timestamp.clone(),
signature_sha1: None,
signature_sha1: Some(update_log_sig),
},
);