Skip to content

Commit

Permalink
fix bug of adding category with quotes (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
shenjiangqiu authored Dec 5, 2024
1 parent c51014d commit 6b63683
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub struct Qbit {
state: Mutex<LoginState>,
}


impl Qbit {
/// Create a new [`QbitBuilder`] to build a [`Qbit`] instance.
pub fn builder() -> QbitBuilder {
Expand Down Expand Up @@ -516,6 +515,13 @@ impl Qbit {
.unwrap()
.into_iter()
.fold(reqwest::multipart::Form::new(), |form, (k, v)| {
// If we directly call to_string() on a Value containing a string like "hello",
// it will include the quotes: "\"hello\"".
// We need to use as_str() first to get the inner string without quotes.
let v = match v.as_str() {
Some(v_str) => v_str.to_string(),
None => v.to_string(),
};
form.text(k.to_string(), v.to_string())
}),
|mut form, torrent| {
Expand Down Expand Up @@ -1510,7 +1516,11 @@ impl Qbit {
impl Clone for Qbit {
fn clone(&self) -> Self {
let state = self.state.lock().unwrap().clone();
Self { client: self.client.clone(), endpoint: self.endpoint.clone(), state: Mutex::new(state) }
Self {
client: self.client.clone(),
endpoint: self.endpoint.clone(),
state: Mutex::new(state),
}
}
}

Expand Down Expand Up @@ -1694,5 +1704,4 @@ mod test {
.unwrap();
print!("{:#?}", list);
}

}

0 comments on commit 6b63683

Please sign in to comment.