Skip to content

Commit

Permalink
Added destination_fodler to TorrentDetailsResponse (#263)
Browse files Browse the repository at this point in the history
* Added destination folder to torrent detail response.

* clean up changes not needed

* cleaned up launch.json and renamed to destination_folder to output_folder
  • Loading branch information
markolo25 authored Oct 29, 2024
1 parent 588e6cd commit fb6822c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/librqbit/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -454,6 +458,7 @@ pub struct TorrentDetailsResponse {
pub info_hash: String,
pub name: Option<String>,
pub files: Vec<TorrentDetailsResponseFile>,
pub output_folder: String,
}

#[derive(Serialize, Deserialize)]
Expand All @@ -468,6 +473,7 @@ fn make_torrent_details(
info_hash: &Id20,
info: &TorrentMetaV1Info<ByteBufOwned>,
only_files: Option<&[usize]>,
output_folder: String,
) -> Result<TorrentDetailsResponse> {
let files = info
.iter_filenames_and_lengths()
Expand Down Expand Up @@ -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,
})
}

Expand Down

0 comments on commit fb6822c

Please sign in to comment.