Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(rust): Format timestamps as ISO 8601 in metadata JSON

Manav Rathic4830732fdf3
diff --git a/rust/src/commands/export.rs b/rust/src/commands/export.rs
index df4b0ad5eb..fbff19019d 100644
--- a/rust/src/commands/export.rs
+++ b/rust/src/commands/export.rs
@@ -198,22 +198,17 @@ async fn export_account(storage: &Storage, account: &Account, filter: &ExportFil
};
// Decrypt collection name if it's encrypted
- if collection.name.as_ref().map_or(true, |n| n.is_empty()) {
- if let Some(ref encrypted_name) = collection.encrypted_name {
- if let Some(ref nonce) = collection.name_decryption_nonce {
- match decrypt_collection_name(encrypted_name, nonce, &collection_key) {
- Ok(name) => {
- log::debug!("Decrypted collection {} name: {}", collection.id, name);
- collection.name = Some(name);
- }
- Err(e) => {
- log::warn!(
- "Failed to decrypt collection {} name: {}",
- collection.id,
- e
- );
- }
- }
+ if collection.name.as_ref().is_none_or(|n| n.is_empty())
+ && let Some(ref encrypted_name) = collection.encrypted_name
+ && let Some(ref nonce) = collection.name_decryption_nonce
+ {
+ match decrypt_collection_name(encrypted_name, nonce, &collection_key) {
+ Ok(name) => {
+ log::debug!("Decrypted collection {} name: {}", collection.id, name);
+ collection.name = Some(name);
+ }
+ Err(e) => {
+ log::warn!("Failed to decrypt collection {} name: {}", collection.id, e);
}
}
}
@@ -226,7 +221,7 @@ async fn export_account(storage: &Storage, account: &Account, filter: &ExportFil
let mut all_files = Vec::new();
// Iterate through each collection and fetch its files
- for (collection_id, _) in &collection_map {
+ for collection_id in collection_map.keys() {
let mut has_more = true;
let mut since_time = 0i64;
diff --git a/rust/src/models/export_metadata.rs b/rust/src/models/export_metadata.rs
index b01dd9251c..af4d5a1c8a 100644
--- a/rust/src/models/export_metadata.rs
+++ b/rust/src/models/export_metadata.rs
@@ -1,4 +1,27 @@
-use serde::{Deserialize, Serialize};
+use chrono::{Local, TimeZone};
+use serde::{Deserialize, Serialize, Serializer};
+
+/// Custom serializer for timestamp fields to match Go CLI's ISO 8601 format
+fn serialize_timestamp_as_iso8601<S>(
+ timestamp_micros: &i64,
+ serializer: S,
+) -> Result<S::Ok, S::Error>
+where
+ S: Serializer,
+{
+ let timestamp_secs = timestamp_micros / 1_000_000;
+ let timestamp_nanos = ((timestamp_micros % 1_000_000) * 1000) as u32;
+
+ let datetime = Local
+ .timestamp_opt(timestamp_secs, timestamp_nanos)
+ .single()
+ .ok_or_else(|| serde::ser::Error::custom("Invalid timestamp"))?;
+
+ // Format with milliseconds and timezone offset (matching Go CLI format)
+ let iso_string = datetime.to_rfc3339_opts(chrono::SecondsFormat::Millis, true);
+
+ serializer.serialize_str(&iso_string)
+}
/// Album metadata matching Go's export.AlbumMetadata structure
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -37,8 +60,10 @@ pub struct DiskFileMetadata {
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option<Location>,
- pub creation_time: i64, // Unix timestamp in microseconds
- pub modification_time: i64, // Unix timestamp in microseconds
+ #[serde(serialize_with = "serialize_timestamp_as_iso8601")]
+ pub creation_time: i64, // Unix timestamp in microseconds (serialized as ISO 8601)
+ #[serde(serialize_with = "serialize_timestamp_as_iso8601")]
+ pub modification_time: i64, // Unix timestamp in microseconds (serialized as ISO 8601)
pub info: FileInfo,
/// Meta filename on disk (excluded from JSON)
#[serde(skip)]