From 312cdb03c949e06d2f5e3267a5e7c7e5bcd6f51e Mon Sep 17 00:00:00 2001 From: Igor Katson Date: Thu, 7 Nov 2024 14:08:24 +0000 Subject: [PATCH] Fix a bug and tests --- crates/librqbit_core/src/torrent_metainfo.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/librqbit_core/src/torrent_metainfo.rs b/crates/librqbit_core/src/torrent_metainfo.rs index adae7b5..89aa185 100644 --- a/crates/librqbit_core/src/torrent_metainfo.rs +++ b/crates/librqbit_core/src/torrent_metainfo.rs @@ -100,11 +100,15 @@ pub struct TorrentMetaV1Info { // Single-file mode #[serde(skip_serializing_if = "Option::is_none")] pub length: Option, - #[serde(default = "none")] + #[serde(default = "none", skip_serializing_if = "Option::is_none")] pub attr: Option, - #[serde(default = "none")] + #[serde(default = "none", skip_serializing_if = "Option::is_none")] pub sha1: Option, - #[serde(default = "none", rename = "symlink path")] + #[serde( + default = "none", + rename = "symlink path", + skip_serializing_if = "Option::is_none" + )] pub symlink_path: Option>, #[serde(skip_serializing_if = "Option::is_none")] @@ -314,11 +318,15 @@ pub struct TorrentMetaV1File { pub length: u64, pub path: Vec, - #[serde(default = "none")] + #[serde(default = "none", skip_serializing_if = "Option::is_none")] pub attr: Option, - #[serde(default = "none")] + #[serde(default = "none", skip_serializing_if = "Option::is_none")] pub sha1: Option, - #[serde(default = "none", rename = "symlink path")] + #[serde( + default = "none", + rename = "symlink path", + skip_serializing_if = "Option::is_none" + )] pub symlink_path: Option>, }