diff --git a/crates/librqbit/src/http_api.rs b/crates/librqbit/src/http_api.rs index ab20d0bc..729bdcc7 100644 --- a/crates/librqbit/src/http_api.rs +++ b/crates/librqbit/src/http_api.rs @@ -276,6 +276,7 @@ fn json_or_404(idx: usize, v: Option) -> warp::reply::Response pub struct TorrentAddQueryParams { pub overwrite: Option, pub output_folder: Option, + pub sub_folder: Option, pub only_files_regex: Option, pub list_only: Option, } @@ -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() }; diff --git a/crates/librqbit/src/http_api_client.rs b/crates/librqbit/src/http_api_client.rs index 569e2f4f..01339d61 100644 --- a/crates/librqbit/src/http_api_client.rs +++ b/crates/librqbit/src/http_api_client.rs @@ -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(¶ms).unwrap(); diff --git a/crates/librqbit/src/session.rs b/crates/librqbit/src/session.rs index da9705bc..6f51da98 100644 --- a/crates/librqbit/src/session.rs +++ b/crates/librqbit/src/session.rs @@ -124,6 +124,7 @@ pub struct AddTorrentOptions { pub overwrite: bool, pub list_only: bool, pub output_folder: Option, + pub sub_folder: Option, pub peer_opts: Option, pub force_tracker_interval: Option, } @@ -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,