Can now try to unpause errored torrent
This commit is contained in:
parent
e3a3f71064
commit
3de67d0902
4 changed files with 33 additions and 16 deletions
14
TODO.md
14
TODO.md
|
|
@ -14,16 +14,20 @@
|
|||
- [x] pause/unpause
|
||||
- [x] remove including from disk
|
||||
- [ ] DHT
|
||||
- [ ] for torrents with a few seeds might be cool to re-query DHT once in a while
|
||||
- [ ] for torrents with a few seeds might be cool to re-query DHT once in a while.
|
||||
- [x] it's sending many requests now way too fast, locks up Mac OS UI annoyingly
|
||||
|
||||
someday:
|
||||
- [ ] cancellation from the client-side for the lib (i.e. stop the torrent manager)
|
||||
- [x] cancellation from the client-side for the lib (i.e. stop the torrent manager)
|
||||
|
||||
|
||||
refactor:
|
||||
- [x] where are peers stored
|
||||
- [x] http api pause/unpause etc
|
||||
- [ ] when a live torrent fails writing to disk, it should transition to error state
|
||||
- [ ] something is wrong when unpausing - can't finish. Recalculate needed/have from chunk tracker.
|
||||
- [ ] silence this: WARN torrent{id=0}:external_peer_adder: librqbit::spawn_utils: finished with error: no longer live
|
||||
- [x] when a live torrent fails writing to disk, it should transition to error state
|
||||
- [x] something is wrong when unpausing - can't finish. Recalculate needed/have from chunk tracker.
|
||||
- [x] silence this: WARN torrent{id=0}:external_peer_adder: librqbit::spawn_utils: finished with error: no longer live
|
||||
|
||||
- [x] start from error state should be possible from UI
|
||||
- [ ] if the torrent was completed, not need to re-check it
|
||||
- [ ] checking is very slow on raspberry
|
||||
|
|
@ -192,7 +192,11 @@ impl ManagedTorrent {
|
|||
);
|
||||
};
|
||||
|
||||
let spawn_peer_adder = |live: &Arc<TorrentStateLive>| {
|
||||
fn spawn_peer_adder(
|
||||
live: &Arc<TorrentStateLive>,
|
||||
initial_peers: Vec<SocketAddr>,
|
||||
peer_rx: Option<impl StreamExt<Item = SocketAddr> + Unpin + Send + Sync + 'static>,
|
||||
) {
|
||||
let span = live.meta().span.clone();
|
||||
let live = Arc::downgrade(live);
|
||||
spawn(
|
||||
|
|
@ -209,10 +213,11 @@ impl ManagedTorrent {
|
|||
|
||||
if let Some(mut peer_rx) = peer_rx {
|
||||
while let Some(peer) = peer_rx.next().await {
|
||||
live.upgrade()
|
||||
.context("no longer live")?
|
||||
.add_peer_if_not_seen(peer)
|
||||
.context("torrent closed")?;
|
||||
let live = match live.upgrade() {
|
||||
Some(live) => live,
|
||||
None => return Ok(()),
|
||||
};
|
||||
live.add_peer_if_not_seen(peer).context("torrent closed")?;
|
||||
}
|
||||
} else {
|
||||
error!("peer rx is not set");
|
||||
|
|
@ -221,7 +226,7 @@ impl ManagedTorrent {
|
|||
Ok(())
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
match &g.state {
|
||||
ManagedTorrentState::Live(_) => {
|
||||
|
|
@ -254,7 +259,7 @@ impl ManagedTorrent {
|
|||
g.state = ManagedTorrentState::Live(live.clone());
|
||||
|
||||
spawn_fatal_errors_receiver(&t, rx);
|
||||
spawn_peer_adder(&live);
|
||||
spawn_peer_adder(&live, initial_peers, peer_rx);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -274,11 +279,19 @@ impl ManagedTorrent {
|
|||
let live = TorrentStateLive::new(paused, tx);
|
||||
g.state = ManagedTorrentState::Live(live.clone());
|
||||
spawn_fatal_errors_receiver(self, rx);
|
||||
spawn_peer_adder(&live);
|
||||
spawn_peer_adder(&live, initial_peers, peer_rx);
|
||||
Ok(())
|
||||
}
|
||||
ManagedTorrentState::Error(_) => {
|
||||
bail!("starting torrents from error state not implemented")
|
||||
let initializing = Arc::new(TorrentStateInitializing::new(
|
||||
self.info.clone(),
|
||||
self.only_files.clone(),
|
||||
));
|
||||
g.state = ManagedTorrentState::Initializing(initializing.clone());
|
||||
drop(g);
|
||||
|
||||
// Recurse.
|
||||
self.start(initial_peers, peer_rx, start_paused)
|
||||
}
|
||||
ManagedTorrentState::None => bail!("bug: torrent is in empty state"),
|
||||
}
|
||||
|
|
|
|||
2
crates/librqbit/webui/dist/app.js
vendored
2
crates/librqbit/webui/dist/app.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -106,7 +106,7 @@ const TorrentActions: React.FC<{
|
|||
let refreshCtx = useContext(RefreshTorrentStatsContext);
|
||||
|
||||
const canPause = state == 'live';
|
||||
const canUnpause = state == 'paused';
|
||||
const canUnpause = state == 'paused' || state == 'error';
|
||||
|
||||
const ctx = useContext(AppContext);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue