Skip to content

Commit

Permalink
Merge pull request #9 from pcmid/pcmid/update/target_dir
Browse files Browse the repository at this point in the history
Update: add sub_folder in AddTorrentOptions
  • Loading branch information
ikatson authored Oct 25, 2021
2 parents 81cf94b + 681e93a commit 804303c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/librqbit/src/http_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ fn json_or_404<T: Serialize>(idx: usize, v: Option<T>) -> warp::reply::Response
pub struct TorrentAddQueryParams {
pub overwrite: Option<bool>,
pub output_folder: Option<String>,
pub sub_folder: Option<String>,
pub only_files_regex: Option<String>,
pub list_only: Option<bool>,
}
Expand Down Expand Up @@ -362,6 +363,7 @@ impl HttpApi {
overwrite: params.overwrite.unwrap_or(false),
only_files_regex: params.only_files_regex,
output_folder: params.output_folder,
sub_folder: params.sub_folder,
list_only: params.list_only.unwrap_or(false),
..Default::default()
};
Expand Down
1 change: 1 addition & 0 deletions crates/librqbit/src/http_api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl HttpApiClient {
overwrite: Some(opts.overwrite),
only_files_regex: opts.only_files_regex,
output_folder: opts.output_folder,
sub_folder: opts.sub_folder,
list_only: Some(opts.list_only),
};
let qs = serde_urlencoded::to_string(&params).unwrap();
Expand Down
5 changes: 4 additions & 1 deletion crates/librqbit/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub struct AddTorrentOptions {
pub overwrite: bool,
pub list_only: bool,
pub output_folder: Option<String>,
pub sub_folder: Option<String>,
pub peer_opts: Option<PeerConnectionOptions>,
pub force_tracker_interval: Option<Duration>,
}
Expand Down Expand Up @@ -318,10 +319,12 @@ impl Session {
}));
}

let sub_folder = opts.sub_folder.map(PathBuf::from).unwrap_or_default();
let output_folder = opts
.output_folder
.map(PathBuf::from)
.unwrap_or_else(|| self.output_folder.clone());
.unwrap_or_else(|| self.output_folder.clone())
.join(sub_folder.as_path());

let managed_torrent = ManagedTorrent {
info_hash,
Expand Down

0 comments on commit 804303c

Please sign in to comment.