Switch UI to display statuses better
This commit is contained in:
parent
876afbf41b
commit
66d2f224ed
7 changed files with 80 additions and 26 deletions
|
|
@ -4,7 +4,7 @@ use tracing::{debug, info};
|
|||
|
||||
use crate::type_aliases::BF;
|
||||
|
||||
pub(crate) struct ChunkTracker {
|
||||
pub struct ChunkTracker {
|
||||
// This forms the basis of a "queue" to pull from.
|
||||
// It's set to 1 if we need a piece, but the moment we start requesting a peer,
|
||||
// it's set to 0.
|
||||
|
|
@ -51,7 +51,7 @@ fn compute_chunk_status(lengths: &Lengths, needed_pieces: &BF) -> BF {
|
|||
chunk_bf
|
||||
}
|
||||
|
||||
pub(crate) enum ChunkMarkingResult {
|
||||
pub enum ChunkMarkingResult {
|
||||
PreviouslyCompleted,
|
||||
NotCompleted,
|
||||
Completed,
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ struct StatsResponse {
|
|||
error: Option<String>,
|
||||
progress_bytes: u64,
|
||||
total_bytes: u64,
|
||||
finished: bool,
|
||||
live: Option<LiveStats>,
|
||||
}
|
||||
|
||||
|
|
@ -514,6 +515,7 @@ impl ApiInternal {
|
|||
state: "",
|
||||
error: None,
|
||||
progress_bytes: 0,
|
||||
finished: false,
|
||||
live: None,
|
||||
};
|
||||
|
||||
|
|
@ -526,11 +528,13 @@ impl ApiInternal {
|
|||
ManagedTorrentState::Paused(p) => {
|
||||
resp.state = "paused";
|
||||
resp.progress_bytes = p.have_bytes;
|
||||
resp.finished = p.have_bytes == resp.progress_bytes;
|
||||
}
|
||||
ManagedTorrentState::Live(l) => {
|
||||
resp.state = "live";
|
||||
let live_stats = self.make_live_stats(l);
|
||||
resp.progress_bytes = live_stats.snapshot.downloaded_and_checked_bytes;
|
||||
resp.progress_bytes = live_stats.snapshot.have_bytes;
|
||||
resp.finished = resp.progress_bytes == resp.total_bytes;
|
||||
resp.live = Some(live_stats);
|
||||
}
|
||||
ManagedTorrentState::Error(e) => {
|
||||
|
|
|
|||
|
|
@ -438,7 +438,7 @@ impl Session {
|
|||
.as_ref()
|
||||
.map(|dht| dht.get_peers(handle.info_hash()))
|
||||
.transpose()?;
|
||||
handle.start(Default::default(), peer_rx);
|
||||
return Ok(());
|
||||
handle.start(Default::default(), peer_rx)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::time::{Duration, Instant};
|
||||
use std::time::Duration;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue