Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added destination_fodler to TorrentDetailsResponse #263

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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