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,19 +1,14 @@
name: Rust name: Rust
on: on:
push: push:
branches: ["main"] branches: ["main"]
pull_request: pull_request:
branches: ["main"] branches: ["main"]
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Build - name: Build

View File

@ -6,8 +6,8 @@ use super::Torrents;
impl Torrents { impl Torrents {
pub async fn toggle(&mut self, torrent: &Torrent) { pub async fn toggle(&mut self, torrent: &Torrent) {
let id = torrent.id().expect("ID not found"); let id = torrent.id().expect("ID not found");
let action = match torrent.status.expect("Torrent status not found") { let action = match torrent.status {
TorrentStatus::Stopped => TorrentAction::StartNow, Some(TorrentStatus::Stopped) => TorrentAction::StartNow,
_ => TorrentAction::Stop, _ => TorrentAction::Stop,
}; };
self.client self.client
@ -55,8 +55,16 @@ impl Torrents {
todo!() todo!()
} }
pub fn delete(&mut self) -> Result<()> { pub async fn delete(
todo!() &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<()> { pub fn rename(&mut self) -> Result<()> {