Skip to content

Commit 48c6b2f

Browse files
committed
refactor: Attempt to autostart when sufficient_peers or autostart is changed
1 parent 0cba668 commit 48c6b2f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

crates/libtortillas/src/torrent/actor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub(crate) struct TorrentActor {
114114
pub(super) autostart: bool,
115115

116116
/// If there is already a pending start, we don't want to start a new one
117-
pending_start: bool,
117+
pub(super) pending_start: bool,
118118

119119
pub(super) ready_hook: Option<ReadyHook>,
120120
}

crates/libtortillas/src/torrent/messages.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,15 @@ impl Message<TorrentMessage> for TorrentActor {
322322
}
323323
TorrentMessage::SetAutoStart(auto) => {
324324
self.autostart = auto;
325+
if !self.pending_start {
326+
self.autostart().await;
327+
}
325328
}
326329
TorrentMessage::SetSufficientPeers(peers) => {
327330
self.sufficient_peers = peers;
331+
if !self.pending_start {
332+
self.autostart().await;
333+
}
328334
}
329335
TorrentMessage::ReadyHook(hook) => {
330336
// If torrent has already transitioned from Inactive state, immediately send

0 commit comments

Comments
 (0)