Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

The download list shows a torrent's seeders and share ratio (#357) (#408)

Vhierly8d319e6df752
diff --git a/CHANGELOG.md b/CHANGELOG.md
index da014b73..15bc2eee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -38,6 +38,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
- Windows: no more crash when a screen is unplugged, turned off or rearranged while MDM runs ([#335](https://github.com/anefzaoui/misterdownloadmanager/issues/335)).
### Added
+- **Two columns for torrents in the download list** ([#357](https://github.com/anefzaoui/misterdownloadmanager/issues/357)): **Peers** (those a torrent has connected while it runs, seeders and leechers alike) and **Share ratio** (what it has sent against what it took), after **Transfer rate**. A layout saved before them gets them there.
- The extension's **Media on this page** can name a file after its page: **Prefix media file names with the page title** puts the page's title before the file's own name. Off as installed.
- **Far more file types taken from the browser by default** ([#382](https://github.com/anefzaoui/misterdownloadmanager/issues/382)): AI models and datasets (GGUF, SAFETENSORS, CKPT, PT, ONNX, PARQUET...), 3D and CAD (GLB, FBX, OBJ, STL, BLEND, STEP...), design and camera RAW files, ebooks, Office files, DAT, disk images and split archives. A list you never edited gains them; one you edited stays yours.
- **A Safari extension, inside the Mac app:** a click on a link to a file type MDM takes goes to MDM, and so do the right-click items, the button over videos and **Media on this page**, as in the other browsers. Safari gives extensions no access to its downloads, so a download a page starts by itself stays with Safari, and the browser's proxy is not shared. See [Browser integration](docs/browser-integration.md#safari-macos).
diff --git a/ROADMAP.md b/ROADMAP.md
index b5c59fb8..23fd08b2 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -504,6 +504,9 @@ These ship in a later version, when they're ready.
so a download a page starts by itself stays with Safari. Built and its relay to the helper
checked in the sandbox Safari uses; still to check in Safari itself, signed with a Developer ID
+- πŸ”„ A torrent's peers and share ratio as columns in the download list
+ ([#357](https://github.com/anefzaoui/misterdownloadmanager/issues/357)): in review; its upload
+ speed is still to come
- πŸ”„ The browser extension's media list naming a file after its page, as an option: in review
- πŸ”„ Malay: a native speaker's check of the menus, toolbar and list columns: in review
diff --git a/crates/app/src/app.rs b/crates/app/src/app.rs
index 9a0effd5..4f16cf2e 100644
--- a/crates/app/src/app.rs
+++ b/crates/app/src/app.rs
@@ -873,6 +873,18 @@ fn sort_key(it: &Item, col: usize, queued: bool) -> (f64, String) {
// Added: the order of addition itself (ids only grow), exact even without a time.
list::ADDED => (it.id as f64, String::new()),
list::SOURCE => (f64::from(u8::from(it.torrent.is_some())), String::new()),
+ // A torrent's peers, and its share ratio (not the text: "10" would come before "9").
+ // Anything but a torrent, and a torrent that has taken nothing, sort as zero.
+ list::PEERS => (
+ it.torrent.as_ref().map_or(0.0, |t| t.peers as f64),
+ String::new(),
+ ),
+ list::RATIO => (
+ it.torrent.as_ref().map_or(0.0, |t| {
+ crate::torrents::share_ratio(t.uploaded, it.downloaded)
+ }),
+ String::new(),
+ ),
_ => (0.0, it.description.to_lowercase()),
}
}
@@ -1387,6 +1399,14 @@ impl App {
// i18n: where a download comes from: a web or FTP server (shown on a small colored label)
"Web".into()
},
+ // A torrent's own numbers (#357): the peers it has, and what it gave back
+ // against what it took (as the progress window's General tab works it out).
+ it.torrent
+ .as_ref()
+ .map_or(String::new(), |t| crate::i18n::integer(t.peers as u64)),
+ it.torrent.as_ref().map_or(String::new(), |t| {
+ crate::torrents::share_ratio_text(t.uploaded, it.downloaded)
+ }),
],
}
}
@@ -1789,6 +1809,7 @@ impl App {
self.account_at += Duration::from_secs(dt);
}
let Some(t) = self.torrent_host.get() else {
+ crate::torrents::clear_peers(self.items.iter_mut().filter_map(|i| i.torrent.as_mut()));
return;
};
let limits = self.settings.sharing_limits();
@@ -1800,6 +1821,7 @@ impl App {
};
hashes.insert(spec.hash.clone());
let Ok(st) = t.stats(&spec.hash) else {
+ spec.peers = 0;
continue;
};
let sent = self.accountant.sent(&spec.hash, st.uploaded);
@@ -1807,6 +1829,9 @@ impl App {
spec.uploaded += sent;
changed = true;
}
+ // The peers it has now, for the list's "Peers" column (#357). Not a reason to save:
+ // it changes as peers come and go, and the next tick brings the list up to date.
+ spec.peers = st.peers_live;
if st.phase == mdm_torrent::Phase::Finished && dt > 0 {
spec.seeded_secs += dt;
changed = true;
@@ -3748,6 +3773,7 @@ impl App {
folder,
uploaded: 0,
seeded_secs: 0,
+ peers: 0,
upload_limit: None,
in_order: add.in_order,
ends_first: true,
diff --git a/crates/app/src/list.rs b/crates/app/src/list.rs
index e2980dfc..5cb98607 100644
--- a/crates/app/src/list.rs
+++ b/crates/app/src/list.rs
@@ -44,9 +44,10 @@ themed! {
}
/// Columns, by their fixed data slot in [`Row::cells`]: IDM's eight, then the user's additions:
-/// "Added" (2026-10-30: when the download was added; sorts in order of addition) and "Source"
-/// (D-014: a Web or Torrent chip, first by default).
-pub const COLS: usize = 10;
+/// "Added" (2026-10-30: when the download was added; sorts in order of addition), "Source"
+/// (D-014: a Web or Torrent chip, first by default), and a torrent's "Peers" and "Share ratio"
+/// (#357: how many peers it has connected and what it has given back).
+pub const COLS: usize = 12;
pub const TITLES: [&str; COLS] = [
"File Name",
// i18n: column title: one letter for Queue (the column is narrow)
@@ -64,19 +65,28 @@ pub const TITLES: [&str; COLS] = [
"Added",
// i18n: noun: where the download comes from (Web or Torrent)
"Source",
+ // i18n: column title: how many peers a torrent is connected to now (seeders and leechers)
+ "Peers",
+ // i18n: column title: what a torrent has sent to peers against what it took
+ "Share ratio",
];
/// The "Added" column's data slot.
pub const ADDED: usize = 8;
/// The "Source" column's data slot: its cell is "Web" or "Torrent", painted as a chip.
pub const SOURCE: usize = 9;
+/// The "Peers" column's data slot (a torrent's connected peers; blank for anything else).
+pub const PEERS: usize = 10;
+/// The "Share ratio" column's data slot (a torrent's sent over taken; blank otherwise).
+pub const RATIO: usize = 11;
/// IDM's default column widths (and ours for Added, room for a 12-hour clock's
-/// `Oct 28 9:05:01 AM 2026`, and Source).
+/// `Oct 28 9:05:01 AM 2026`, Source, Peers and Share ratio).
pub const DEFAULT_WIDTHS: [f32; COLS] = [
- 150.0, 20.0, 75.0, 65.0, 75.0, 95.0, 65.0, 200.0, 145.0, 62.0,
+ 150.0, 20.0, 75.0, 65.0, 75.0, 95.0, 65.0, 200.0, 145.0, 62.0, 64.0, 92.0,
];
-/// Default display order: Source first, then IDM's, with Added after Last Try Date.
-const DEFAULT_ORDER: [usize; COLS] = [SOURCE, 0, 1, 2, 3, 4, 5, 6, ADDED, 7];
+/// Default display order: Source first, then IDM's, a torrent's two columns after its rate, and
+/// Added after Last Try Date.
+const DEFAULT_ORDER: [usize; COLS] = [SOURCE, 0, 1, 2, 3, 4, 5, PEERS, RATIO, 6, ADDED, 7];
const MIN_WIDTH: f32 = 16.0;
/// How far from a separator a press grabs it for resizing.
@@ -241,8 +251,9 @@ impl ListState {
}
/// Restore a saved layout. One saved before "Added" existed gets it after Last Try Date,
- /// one saved before "Source" gets it first; a layout that doesn't name every column
- /// exactly once is ignored.
+ /// one saved before "Source" gets it first, one saved before "Peers" and "Share ratio" gets
+ /// them after Transfer rate; a layout that doesn't name every column exactly once is
+ /// ignored.
pub fn apply(&mut self, mut l: Layout) {
if !l.order.contains(&SOURCE) {
l.order.insert(0, SOURCE);
@@ -255,6 +266,22 @@ impl ListState {
.map_or(l.order.len(), |p| p + 1);
l.order.insert(at, ADDED);
}
+ if !l.order.contains(&PEERS) {
+ let at = l
+ .order
+ .iter()
+ .position(|c| *c == 5)
+ .map_or(l.order.len(), |p| p + 1);
+ l.order.insert(at, PEERS);
+ }
+ if !l.order.contains(&RATIO) {
+ let at = l
+ .order
+ .iter()
+ .position(|c| *c == PEERS)
+ .map_or(l.order.len(), |p| p + 1);
+ l.order.insert(at, RATIO);
+ }
let mut seen = l.order.clone();
seen.sort_unstable();
if seen != (0..COLS).collect::<Vec<_>>() {
@@ -1168,7 +1195,8 @@ fn fit_width(p: &egui::Painter, font: &egui::FontId, col: usize, rows: &[Row]) -
fn cell_text(col: usize, s: &str) -> String {
match col {
0 | 7 => crate::i18n::isolate(s),
- 6 | ADDED => crate::i18n::ltr(s),
+ // Dates, a peer count and a ratio read left to right.
+ 6 | ADDED | PEERS | RATIO => crate::i18n::ltr(s),
_ => s.to_owned(),
}
}
@@ -1548,7 +1576,7 @@ mod tests {
}
#[test]
- fn a_layout_saved_before_the_added_column_still_loads() {
+ fn a_layout_saved_before_the_added_columns_still_loads() {
let old = Layout {
order: vec![0, 2, 1, 3, 4, 5, 6, 7],
widths: vec![200.0, 20.0, 75.0, 65.0, 75.0, 95.0, 65.0, 300.0],
@@ -1557,11 +1585,50 @@ mod tests {
};
let mut st = ListState::default();
st.apply(old);
- assert_eq!(st.order, [SOURCE, 0, 2, 1, 3, 4, 5, 6, ADDED, 7]);
+ // Source first, the two torrent columns after Transfer rate, Added after Last Try Date.
+ assert_eq!(
+ st.order,
+ [SOURCE, 0, 2, 1, 3, 4, 5, PEERS, RATIO, 6, ADDED, 7]
+ );
assert_eq!(st.widths[0], 200.0, "the saved widths stay");
assert_eq!(st.widths[ADDED], DEFAULT_WIDTHS[ADDED]);
assert!(st.visible[ADDED]);
assert!(st.visible[SOURCE]);
+ // A layout saved before they existed gets their defaults, shown.
+ assert_eq!(st.widths[PEERS], DEFAULT_WIDTHS[PEERS]);
+ assert_eq!(st.widths[RATIO], DEFAULT_WIDTHS[RATIO]);
+ assert!(st.visible[PEERS] && st.visible[RATIO]);
assert_eq!(st.sort, Some((2, false)));
}
+
+ /// #357: a layout saved between "Source" and the two torrent columns gets them in the same
+ /// place, and a layout that names a column twice is still ignored.
+ #[test]
+ fn a_layout_saved_before_the_torrent_columns_gets_them() {
+ let old = Layout {
+ order: vec![SOURCE, 0, 1, 2, 3, 4, 5, 6, ADDED, 7],
+ widths: vec![
+ 62.0, 150.0, 20.0, 75.0, 65.0, 75.0, 95.0, 65.0, 125.0, 300.0,
+ ],
+ visible: vec![true; 10],
+ sort: None,
+ };
+ let mut st = ListState::default();
+ st.apply(old);
+ assert_eq!(
+ st.order,
+ [SOURCE, 0, 1, 2, 3, 4, 5, PEERS, RATIO, 6, ADDED, 7]
+ );
+ assert!(st.widths[PEERS] > 0.0 && st.widths[RATIO] > 0.0);
+ // A layout that names one column twice (and so misses another) is ignored whole.
+ let bad = Layout {
+ order: vec![SOURCE, 0, 1, 2, 3, 4, 5, 6, ADDED, 7, PEERS, PEERS],
+ widths: vec![62.0; 12],
+ visible: vec![true; 12],
+ sort: None,
+ };
+ let mut st = ListState::default();
+ st.apply(bad);
+ assert_eq!(st.order, DEFAULT_ORDER.to_vec(), "the default stands");
+ }
}
diff --git a/crates/app/src/progress.rs b/crates/app/src/progress.rs
index 78a1e78f..4626e8c9 100644
--- a/crates/app/src/progress.rs
+++ b/crates/app/src/progress.rs
@@ -1227,11 +1227,7 @@ impl Progress {
let spec = item.torrent.as_ref();
let sent = spec.map_or(0, |t| t.uploaded);
let done = st.map_or(item.downloaded, |s| s.done);
- let ratio = if done > 0 {
- crate::i18n::decimal(sent as f64 / done as f64, 2)
- } else {
- crate::i18n::decimal(0.0, 2)
- };
+ let ratio = crate::torrents::share_ratio_text(sent, done);
let shared = spec.map_or(0, |t| t.seeded_secs);
let hash = item
.torrent
diff --git a/crates/app/src/torrents.rs b/crates/app/src/torrents.rs
index 942cbf3e..79f2a3cb 100644
--- a/crates/app/src/torrents.rs
+++ b/crates/app/src/torrents.rs
@@ -31,6 +31,11 @@ pub struct TorrentSpec {
/// Seconds it has spent sharing once finished, in all its runs.
#[serde(default)]
pub seeded_secs: u64,
+ /// Peers connected to it now (#357), for the list's "Peers" column; every connected peer,
+ /// seeders and leechers alike. Live only: never saved, and zero whenever there is no torrent
+ /// session or the session has no numbers for it.
+ #[serde(skip)]
+ pub peers: usize,
/// Its own upload limit, bytes/s (None: only Torrent settings' limit for all torrents).
#[serde(default)]
pub upload_limit: Option<u64>,
@@ -86,7 +91,7 @@ pub fn sharing_limit_reached(
done: u64,
limits: SharingLimits,
) -> Option<Reached> {
- let ratio = spec.uploaded as f64 / done.max(1) as f64;
+ let ratio = share_ratio(spec.uploaded, done);
if let Some(r) = limits.ratio
&& done > 0
&& ratio >= r
@@ -101,6 +106,26 @@ pub fn sharing_limit_reached(
None
}
+/// No session is running: nothing is connected, whatever the list last showed (#357).
+pub fn clear_peers<'a>(specs: impl Iterator<Item = &'a mut TorrentSpec>) {
+ specs.for_each(|t| t.peers = 0);
+}
+
+/// A torrent's share ratio: what it sent to peers against what it has. Zero while it has nothing.
+pub fn share_ratio(sent: u64, done: u64) -> f64 {
+ if done == 0 {
+ 0.0
+ } else {
+ sent as f64 / done as f64
+ }
+}
+
+/// [`share_ratio`] as the interface writes it, in the list and the progress window's General tab:
+/// two decimals, `0.00` while it has nothing.
+pub fn share_ratio_text(sent: u64, done: u64) -> String {
+ crate::i18n::decimal(share_ratio(sent, done), 2)
+}
+
/// Adds up what each torrent sent, run after run: librqbit's count starts at 0 again each time
/// a torrent resumes (and is 0 while it is paused), so a smaller count than the last one seen
/// is all new.
@@ -1012,6 +1037,64 @@ pub fn dest_for(meta: &mdm_torrent::Meta, dir: &Path, files: Option<&[usize]>) -
mod tests {
use super::*;
+ fn a_spec() -> TorrentSpec {
+ TorrentSpec {
+ hash: "h".into(),
+ files: None,
+ folder: "f".into(),
+ uploaded: 0,
+ seeded_secs: 0,
+ peers: 0,
+ upload_limit: None,
+ in_order: false,
+ ends_first: true,
+ }
+ }
+
+ /// #357: the ratio the list and the General tab share, and the seeding limit's.
+ #[test]
+ fn a_torrents_share_ratio() {
+ assert_eq!(share_ratio(0, 0), 0.0);
+ assert_eq!(share_ratio(500, 0), 0.0, "nothing taken: no ratio");
+ assert_eq!(share_ratio(500, 1000), 0.5);
+ assert_eq!(
+ share_ratio_text(0, 0),
+ "0.00",
+ "as the General tab writes it"
+ );
+ assert_eq!(share_ratio_text(500, 1000), "0.50");
+ assert_eq!(share_ratio_text(2000, 1000), "2.00");
+ assert_eq!(share_ratio_text(1, 3), "0.33");
+ }
+
+ /// #357: a torrent's live peer count isn't kept across a restart: it isn't saved and an old
+ /// value in the file is ignored, so a stopped torrent can't show a stale count.
+ #[test]
+ fn a_torrents_peers_are_not_saved() {
+ let mut t = a_spec();
+ t.peers = 7;
+ let saved = serde_json::to_value(&t).unwrap();
+ assert!(saved.get("peers").is_none(), "the count isn't written");
+ let mut with_old = saved.clone();
+ with_old["peers"] = 9.into();
+ with_old["seeders"] = 9.into();
+ let loaded: TorrentSpec = serde_json::from_value(with_old).unwrap();
+ assert_eq!(
+ loaded.peers, 0,
+ "an old value in the file doesn't come back"
+ );
+ }
+
+ /// #357: with no session running, the column says nobody is connected.
+ #[test]
+ fn no_session_means_no_peers() {
+ let mut specs = [a_spec(), a_spec()];
+ specs[0].peers = 3;
+ specs[1].peers = 12;
+ clear_peers(specs.iter_mut());
+ assert_eq!([specs[0].peers, specs[1].peers], [0, 0]);
+ }
+
/// #39: what a torrent sent adds up across its runs: librqbit's count is 0 while paused
/// and starts again at 0 on each resume.
#[test]
@@ -1066,6 +1149,7 @@ mod tests {
folder: "f".into(),
uploaded,
seeded_secs,
+ peers: 0,
upload_limit: None,
in_order: false,
ends_first: true,
diff --git a/docs/download-list.md b/docs/download-list.md
index 29333778..78b0ac6e 100644
--- a/docs/download-list.md
+++ b/docs/download-list.md
@@ -26,6 +26,8 @@ branches and the category or queue you were looking at.
| **Status** | How far it is, or **Complete**, **Error** and so on. |
| **Time left** | While it downloads. |
| **Transfer rate** | The current speed. |
+| **Peers** | A torrent's connected peers while it runs, seeders and leechers alike. |
+| **Share ratio** | A torrent: what it has sent to peers against what it took. |
| **Last Try Date** | When it last ran. |
| **Added** | When you added it. |
| **Description** | Your note from **Download File Info** or **Properties**. |
diff --git a/i18n/en.tsv b/i18n/en.tsv
index 0478eded..95b0984e 100644
--- a/i18n/en.tsv
+++ b/i18n/en.tsv
@@ -4090,12 +4090,18 @@ column File Name File Name
#. column title in the download list in the download list
column Last Try Date Last Try Date
#. column title in the download list in the download list
+#. column title: how many peers a torrent is connected to now (seeders and leechers)
+column Peers Peers
+#. column title in the download list in the download list
#. column title: one letter for Queue (the column is narrow)
column Q Q
#. column title in the main window; column title in the download list
#. tooltip of the narrow "Q" column's title
column Queue Queue
#. column title in the download list in the download list
+#. column title: what a torrent has sent to peers against what it took
+column Share ratio Share ratio
+#. column title in the download list in the download list
#. noun: the file's size
column Size Size
#. column title in the download list in the download list