diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 31000a2..68d614a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -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 diff --git a/src/app/command.rs b/src/app/command.rs index 0028b2a..1be5fc0 100644 --- a/src/app/command.rs +++ b/src/app/command.rs @@ -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<()> {