From fb6822ca41e5c14dde48d27e12b2308b949a44b1 Mon Sep 17 00:00:00 2001 From: Mark Mendoza Date: Tue, 29 Oct 2024 02:50:21 -0700 Subject: [PATCH] Added destination_fodler to TorrentDetailsResponse (#263) * Added destination folder to torrent detail response. * clean up changes not needed * cleaned up launch.json and renamed to destination_folder to output_folder --- crates/librqbit/src/api.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/librqbit/src/api.rs b/crates/librqbit/src/api.rs index 4dfc0d50..369562d3 100644 --- a/crates/librqbit/src/api.rs +++ b/crates/librqbit/src/api.rs @@ -208,7 +208,9 @@ impl Api { let handle = self.mgr_handle(idx)?; let info_hash = handle.shared().info_hash; let only_files = handle.only_files(); - make_torrent_details(&info_hash, &handle.shared().info, only_files.as_deref()) + let output_folder = handle.shared().options.output_folder.to_string_lossy().into_owned().to_string(); + make_torrent_details(&info_hash, &handle.shared().info, only_files.as_deref(), output_folder) + } pub fn api_session_stats(&self) -> SessionStatsSnapshot { @@ -341,6 +343,7 @@ impl Api { &handle.info_hash(), &handle.shared().info, handle.only_files().as_deref(), + handle.shared().options.output_folder.to_string_lossy().into_owned(), ) .context("error making torrent details")?; ApiAddTorrentResponse { @@ -366,14 +369,15 @@ impl Api { id: None, output_folder: output_folder.to_string_lossy().into_owned(), seen_peers: Some(seen_peers), - details: make_torrent_details(&info_hash, &info, only_files.as_deref()) + details: make_torrent_details(&info_hash, &info, only_files.as_deref(), output_folder.to_string_lossy().into_owned().to_string()) .context("error making torrent details")?, }, AddTorrentResponse::Added(id, handle) => { let details = make_torrent_details( &handle.info_hash(), &handle.shared().info, - handle.only_files().as_deref(), + handle.only_files().as_deref(), + handle.shared().options.output_folder.to_string_lossy().into_owned(), ) .context("error making torrent details")?; ApiAddTorrentResponse { @@ -454,6 +458,7 @@ pub struct TorrentDetailsResponse { pub info_hash: String, pub name: Option, pub files: Vec, + pub output_folder: String, } #[derive(Serialize, Deserialize)] @@ -468,6 +473,7 @@ fn make_torrent_details( info_hash: &Id20, info: &TorrentMetaV1Info, only_files: Option<&[usize]>, + output_folder: String, ) -> Result { let files = info .iter_filenames_and_lengths() @@ -495,6 +501,7 @@ fn make_torrent_details( info_hash: info_hash.as_string(), name: info.name.as_ref().map(|b| b.to_string()), files, + output_folder, }) }