Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Downloads: seeding torrents shown with ratio; the add-on registers its own parts

gelenmedyade8b9d689a05
diff --git a/crates/rf-app/src/downloads_view.rs b/crates/rf-app/src/downloads_view.rs
index d9f0668b..7f7488e3 100644
--- a/crates/rf-app/src/downloads_view.rs
+++ b/crates/rf-app/src/downloads_view.rs
@@ -63,6 +63,9 @@ pub struct Live {
pub error: String,
/// The file list waits for the user's choice.
pub choosing: bool,
+ /// A finished torrent that goes on sharing until its ratio or time limit (HyperDownload issue 5), and what it has sent.
+ pub seeding: bool,
+ pub uploaded: u64,
pub eta: Option<u64>,
}
@@ -99,6 +102,8 @@ pub fn live_of(v: &Value) -> Live {
map: v.get("hdMap").and_then(Value::as_str).unwrap_or_default().to_string(),
error: v.get("errorMessage").and_then(Value::as_str).unwrap_or_default().to_string(),
choosing: v.get("hdChoice").and_then(Value::as_bool) == Some(true),
+ seeding: v.get("hdSeeding").and_then(Value::as_bool) == Some(true),
+ uploaded: num(v, "uploadLength"),
eta,
}
}
@@ -163,7 +168,7 @@ impl DownloadsView {
let total: u64 = live.as_ref().map_or(0, |l| l.iter().map(|d| d.speed).sum());
// nothing downloading (all finished, cancelled or paused): the skyline goes, it does not stand on for a minute
// as if something were still running (HyperDownload issue 3)
- let running = live.as_ref().is_some_and(|l| l.iter().any(|d| d.status == "active"));
+ let running = live.as_ref().is_some_and(|l| l.iter().any(|d| d.status == "active" && !d.seeding));
let emptied = !running && total == 0 && !v.speeds.is_empty();
if running || total > 0 {
v.speeds.push_back(total);
@@ -452,10 +457,22 @@ fn live_row(d: &Live, p: &Palette, me: WeakEntity<DownloadsView>) -> AnyElement
let paused = d.status == "paused";
let failed = d.status == "error";
let sizes = if d.total > 0 { format!("{} / {}", format::size(d.done), format::size(d.total)) } else { format::size(d.done) };
- let speed = if paused { t!("Duraklatıldı").to_string() } else if d.speed > 0 { crate::transfer_view::speed_text(d.speed as f64) } else { String::new() };
+ let speed = if paused {
+ t!("Duraklatıldı").to_string()
+ } else if d.seeding {
+ t!("Paylaşılıyor").to_string()
+ } else if d.speed > 0 {
+ crate::transfer_view::speed_text(d.speed as f64)
+ } else {
+ String::new()
+ };
let eta = d.eta.filter(|_| !paused && d.speed > 0).map(eta_text).unwrap_or_default();
let caption = if d.choosing {
t!("Dosyaların seçilmesi bekleniyor").to_string()
+ } else if d.seeding {
+ // what it gave back, and the share of the download that is
+ let ratio = if d.total > 0 { d.uploaded as f64 / d.total as f64 } else { 0.0 };
+ format!("{} {} · {} {:.2} · {} {}", d.links, t!("eş"), t!("oran"), ratio, format::size(d.uploaded), t!("gönderildi"))
} else if failed {
d.error.clone()
} else if d.torrent {
diff --git a/crates/rf-app/src/hyperdownload.rs b/crates/rf-app/src/hyperdownload.rs
index 83f51240..5d5292f7 100644
--- a/crates/rf-app/src/hyperdownload.rs
+++ b/crates/rf-app/src/hyperdownload.rs
@@ -53,6 +53,17 @@ pub fn register_host() {
let _ = k.set_string("", manifest_path.to_string_lossy().as_ref());
}
}
+ // the add-on's own registration on top: Firefox's host, "Open with" for .torrent files and magnet links when nothing else takes
+ // them (HyperDownload issues 6 and 7); an older add-on knows only the browsers' part, the same as above
+ let mut cmd = std::process::Command::new(&exe);
+ cmd.arg("--register");
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x0800_0000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+ let _ = cmd.spawn();
}
/// Before the add-on is removed: the browsers forget the host.
@@ -60,8 +71,27 @@ pub fn unregister_host() {
if std::env::var_os("RUSTYFILES_CONFIG_DIR").is_some_and(|d| !d.is_empty()) {
return;
}
+ // the add-on's own entries first, while its program is still there (Firefox's host, "Open with", the magnet handler it set)
+ if let Some(exe) = crate::addons::program(ID) {
+ let mut cmd = std::process::Command::new(&exe);
+ cmd.arg("--unregister");
+ #[cfg(windows)]
+ {
+ use std::os::windows::process::CommandExt;
+ const CREATE_NO_WINDOW: u32 = 0x0800_0000;
+ cmd.creation_flags(CREATE_NO_WINDOW);
+ }
+ if let Ok(mut child) = cmd.spawn() {
+ // (a few registry writes: it is done long before this, and a stuck one must not hold the removal)
+ let until = std::time::Instant::now() + std::time::Duration::from_secs(3);
+ while std::time::Instant::now() < until && matches!(child.try_wait(), Ok(None)) {
+ std::thread::sleep(std::time::Duration::from_millis(50));
+ }
+ }
+ }
for key in HOST_KEYS {
- if let Ok(k) = windows_registry::CURRENT_USER.open(key) {
+ // (opened for writing: `open` alone gives a read-only key, and removing under it failed quietly)
+ if let Ok(k) = windows_registry::CURRENT_USER.options().read().write().open(key) {
let _ = k.remove_tree(HOST_NAME);
}
}
diff --git a/crates/rf-app/src/i18n_en.rs b/crates/rf-app/src/i18n_en.rs
index acf5114e..17d12cc8 100644
--- a/crates/rf-app/src/i18n_en.rs
+++ b/crates/rf-app/src/i18n_en.rs
@@ -2331,6 +2331,8 @@ pub const EN: &[(&str, &str)] = &[
("Gelen dosyaların klasörünü seçin", "Choose the folder for received files"),
("İndirme klasörü", "Download folder"),
("İndirmelerin klasörünü seçin", "Choose the folder for downloads"),
+ ("oran", "ratio"),
+ ("gönderildi", "sent"),
("Çift bölmede her bölmenin yolu", "Each pane's path in dual pane"),
("Her bölmenin üstünde kendi klasörünün yolu durur; adres çubuğu yalnızca etkin bölmeninkini gösterir", "Each pane shows its own folder's path above it; the address bar shows only the active pane's"),
("Bu sürücü BitLocker ile kilitli. Kilidini açmak için Windows'un parola penceresi açıldı.", "This drive is locked by BitLocker. Windows' password window opened to unlock it."),