fix: transactional pause

This commit is contained in:
Ivan Moiseev 2024-10-12 15:17:19 +02:00
parent 7147313846
commit b105a3bb22

View file

@ -1365,8 +1365,19 @@ impl Session {
}
pub async fn pause(&self, handle: &ManagedTorrentHandle) -> anyhow::Result<()> {
let mut g = handle.locked.write();
let prev = g.paused;
g.paused = true;
drop(g);
handle.locked.write().paused = true;
handle.pause()?;
match handle.pause() {
Ok(()) => {}
Err(err) => {
handle.locked.write().paused = prev;
return Err(err);
}
}
self.try_update_persistence_metadata(handle).await;
Ok(())
}