feat: add delete torrent

This commit is contained in:
Kristofers Solo 2024-01-31 16:12:18 +02:00
parent b064faa400
commit e0e95b07b1
2 changed files with 19 additions and 16 deletions

View File

@ -1,22 +1,17 @@
name: Rust
on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

View File

@ -6,8 +6,8 @@ use super::Torrents;
impl Torrents {
pub async fn toggle(&mut self, torrent: &Torrent) {
let id = torrent.id().expect("ID not found");
let action = match torrent.status.expect("Torrent status not found") {
TorrentStatus::Stopped => TorrentAction::StartNow,
let action = match torrent.status {
Some(TorrentStatus::Stopped) => TorrentAction::StartNow,
_ => TorrentAction::Stop,
};
self.client
@ -55,8 +55,16 @@ impl Torrents {
todo!()
}
pub fn delete(&mut self) -> Result<()> {
todo!()
pub async fn delete(
&mut self,
torrent: &Torrent,
delete_local_data: bool,
) -> transmission_rpc::types::Result<()> {
let id = torrent.id().expect("ID not found");
self.client
.torrent_remove(vec![id], delete_local_data)
.await?;
Ok(())
}
pub fn rename(&mut self) -> Result<()> {