diff --git a/crates/librqbit/src/create_torrent_file.rs b/crates/librqbit/src/create_torrent_file.rs index caecaef..18ea5dc 100644 --- a/crates/librqbit/src/create_torrent_file.rs +++ b/crates/librqbit/src/create_torrent_file.rs @@ -124,7 +124,13 @@ async fn create_torrent_raw<'a>( .components() .map(|c| osstr_to_bytes(c.as_os_str()).into()) .collect(); - output_files.push(TorrentMetaV1File { length, path }); + output_files.push(TorrentMetaV1File { + length, + path, + attr: None, + sha1: None, + symlink_path: None, + }); continue 'outer; } @@ -154,6 +160,9 @@ async fn create_torrent_raw<'a>( } else { Some(output_files) }, + attr: None, + sha1: None, + symlink_path: None, }) } diff --git a/crates/librqbit/src/upnp_server_adapter.rs b/crates/librqbit/src/upnp_server_adapter.rs index 7a2e278..d91b0e7 100644 --- a/crates/librqbit/src/upnp_server_adapter.rs +++ b/crates/librqbit/src/upnp_server_adapter.rs @@ -402,9 +402,15 @@ mod tests { .map(|f| TorrentMetaV1File { length: 1, path: f.split("/").map(|f| f.as_bytes().into()).collect(), + attr: None, + sha1: None, + symlink_path: None, }) .collect(), ), + attr: None, + sha1: None, + symlink_path: None, }, comment: None, created_by: None, diff --git a/crates/librqbit_core/src/torrent_metainfo.rs b/crates/librqbit_core/src/torrent_metainfo.rs index ee61bd5..6dfd5cc 100644 --- a/crates/librqbit_core/src/torrent_metainfo.rs +++ b/crates/librqbit_core/src/torrent_metainfo.rs @@ -99,6 +99,12 @@ pub struct TorrentMetaV1Info { // Single-file mode #[serde(skip_serializing_if = "Option::is_none")] pub length: Option, + #[serde(default = "none")] + pub attr: Option, + #[serde(default = "none")] + pub sha1: Option, + #[serde(default = "none", rename = "symlink path")] + pub symlink_path: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub md5sum: Option, @@ -253,10 +259,21 @@ impl> TorrentMetaV1Info { } } +const fn none() -> Option { + None +} + #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] pub struct TorrentMetaV1File { pub length: u64, pub path: Vec, + + #[serde(default = "none")] + pub attr: Option, + #[serde(default = "none")] + pub sha1: Option, + #[serde(default = "none", rename = "symlink path")] + pub symlink_path: Option>, } impl TorrentMetaV1File @@ -282,6 +299,9 @@ where TorrentMetaV1File { length: self.length, path: self.path.clone_to_owned(within_buffer), + attr: self.attr.clone_to_owned(within_buffer), + sha1: self.sha1.clone_to_owned(within_buffer), + symlink_path: self.symlink_path.clone_to_owned(within_buffer), } } } @@ -300,6 +320,9 @@ where length: self.length, md5sum: self.md5sum.clone_to_owned(within_buffer), files: self.files.clone_to_owned(within_buffer), + attr: self.attr.clone_to_owned(within_buffer), + sha1: self.sha1.clone_to_owned(within_buffer), + symlink_path: self.symlink_path.clone_to_owned(within_buffer), } } }