Now saving torrent updates properly to the new db

This commit is contained in:
Igor Katson 2024-08-15 11:20:20 +01:00
parent f29dccf8bd
commit d77d96bd48
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
6 changed files with 92 additions and 37 deletions

View file

@ -96,19 +96,21 @@ impl Api {
.per_peer_stats_snapshot(filter))
}
pub fn api_torrent_action_pause(&self, idx: TorrentId) -> Result<EmptyJsonResponse> {
pub async fn api_torrent_action_pause(&self, idx: TorrentId) -> Result<EmptyJsonResponse> {
let handle = self.mgr_handle(idx)?;
handle
.pause()
self.session()
.pause(&handle)
.await
.context("error pausing torrent")
.with_error_status_code(StatusCode::BAD_REQUEST)?;
Ok(Default::default())
}
pub fn api_torrent_action_start(&self, idx: TorrentId) -> Result<EmptyJsonResponse> {
pub async fn api_torrent_action_start(&self, idx: TorrentId) -> Result<EmptyJsonResponse> {
let handle = self.mgr_handle(idx)?;
self.session
.unpause(&handle)
.await
.context("error unpausing torrent")
.with_error_status_code(StatusCode::BAD_REQUEST)?;
Ok(Default::default())
@ -130,7 +132,7 @@ impl Api {
Ok(Default::default())
}
pub fn api_torrent_action_update_only_files(
pub async fn api_torrent_action_update_only_files(
&self,
idx: TorrentId,
only_files: &HashSet<usize>,
@ -138,6 +140,7 @@ impl Api {
let handle = self.mgr_handle(idx)?;
self.session
.update_only_files(&handle, only_files)
.await
.context("error updating only_files")?;
Ok(Default::default())
}