Skip to content

Commit

Permalink
Merge pull request #230 from Artrix9095/main
Browse files Browse the repository at this point in the history
Remove error when adding duplicate torrents
  • Loading branch information
ikatson authored Sep 1, 2024
2 parents 206bcde + 135a505 commit e4670bd
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions crates/librqbit/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,24 @@ impl Api {
.context("error adding torrent")
.with_error_status_code(StatusCode::BAD_REQUEST)?
{
AddTorrentResponse::AlreadyManaged(id, managed) => {
return Err(anyhow::anyhow!(
"{:?} is already managed, id={}",
managed.info_hash(),
id,
))
.with_error_status_code(StatusCode::CONFLICT);
AddTorrentResponse::AlreadyManaged(id, handle) => {
let details = make_torrent_details(
&handle.info_hash(),
&handle.shared().info,
handle.only_files().as_deref(),
)
.context("error making torrent details")?;
ApiAddTorrentResponse {
id: Some(id),
details,
seen_peers: None,
output_folder: handle
.shared()
.options
.output_folder
.to_string_lossy()
.into_owned(),
}
}
AddTorrentResponse::ListOnly(ListOnlyResponse {
info_hash,
Expand Down

0 comments on commit e4670bd

Please sign in to comment.