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.
Rust archive-managerdesktop-appdual-paneexplorer-alternativefile-browserfile-explorerfile-managerfluent-designgpu-acceleratedgpuimacosmicaproductivityquick-lookrustrust-guitabswindowswindows-11windows-explorer
HyperDownload: the chosen folder is used at once; Show in folder opens a tab in the same window
gelenmedya9e2056af55b8
diff --git a/crates/rf-app/src/addons_page.rs b/crates/rf-app/src/addons_page.rsindex 233f04e5..8aebe54d 100644--- a/crates/rf-app/src/addons_page.rs+++ b/crates/rf-app/src/addons_page.rs@@ -155,7 +155,7 @@ fn download_folder_card(p: &Palette, cx: &mut App) -> AnyElement {.children(custom.then(|| {button("hd-downloads-reset", p, t!("Varsayılan"), |_, cx| {crate::settings::update(cx, |s| s.hd_downloads.clear());- crate::hyperdownload::register_host();+ crate::hyperdownload::register_host_with(cx.global::<crate::settings::Settings>());})})).child(button("hd-downloads", p, t!("Değiştir…"), |_, cx| {@@ -168,7 +168,7 @@ fn download_folder_card(p: &Palette, cx: &mut App) -> AnyElement {if let Ok(Some(path)) = rx.await {let _ = cx.update(|cx| {crate::settings::update(cx, |s| s.hd_downloads = path.to_string_lossy().into_owned());- crate::hyperdownload::register_host();+ crate::hyperdownload::register_host_with(cx.global::<crate::settings::Settings>());});}})diff --git a/crates/rf-app/src/downloads_view.rs b/crates/rf-app/src/downloads_view.rsindex 47d2a126..8f94419b 100644--- a/crates/rf-app/src/downloads_view.rs+++ b/crates/rf-app/src/downloads_view.rs@@ -573,8 +573,10 @@ fn done_row(i: usize, e: &Entry, there: bool, p: &Palette) -> AnyElement {.flex_shrink_0().gap_1().when(there, |d| {- d.child(icon_button(("dl-show", i), L::FolderOpen, t!("Klasörde göster"), p).on_click(move |_, _, cx| {- crate::workspace::route_ipc(format!("{}{}", crate::workspace::SELECT_TAB_PREFIX, show.display()), cx);+ d.child(icon_button(("dl-show", i), L::FolderOpen, t!("Klasörde göster"), p).on_click(move |_, window, cx| {+ // (after this window's own update is over: see `show_in_folder_from`)+ let (from, file) = (window.window_handle(), show.clone());+ cx.defer(move |cx| crate::workspace::show_in_folder_from(from, &file, cx));}))}).child(icon_button(("dl-forget", i), L::X, t!("Listeden kaldır"), p).on_click(move |_, _, _| hd_history::forget(&forget))),diff --git a/crates/rf-app/src/hyperdownload.rs b/crates/rf-app/src/hyperdownload.rsindex 02251dbd..0676c775 100644--- a/crates/rf-app/src/hyperdownload.rs+++ b/crates/rf-app/src/hyperdownload.rs@@ -32,11 +32,27 @@ const HOST_KEYS: &[&str] = &[/// rustyfiles' data folder, the Downloads folder and its own exe, so that the host started by a browser finds the same running/// program and shows its downloads here) and the browsers' registration of the host (current user's registry, its own keys only).pub fn register_host() {+ register_host_with(&crate::settings::Settings::load())+}++/// What `host.json` says: the add-on's data folder, the folder downloads go to (`settings`' own, else Windows' Downloads) and+/// the rustyfiles that shows them.+fn host_file(settings: &crate::settings::Settings, data: &Path, me: Option<&Path>) -> Value {+ let downloads = download_folder(settings).unwrap_or_else(|| data.to_path_buf());+ json!({ "data": data, "downloads": downloads, "rustyfiles": me })+}++/// [`register_host`] with the settings as they are NOW.+///+/// WHY (HyperDownload issue 1: "Files get downloaded in the default download folder even after changing the download folder+/// destination"). A change in Settings is saved on a thread of its own, and the registration made right after it read the+/// settings back from the file: mostly the file as it was BEFORE the change, so `host.json` kept the old folder until some later+/// start of the add-on wrote it again. The page now hands over the settings it has just changed.+pub fn register_host_with(settings: &crate::settings::Settings) {let (Some(exe), Some(data)) = (crate::addons::program(ID), data_dir()) else { return };let Some(dir) = exe.parent() else { return };- let downloads = download_folder(&crate::settings::Settings::load()).unwrap_or_else(|| data.clone());let me = std::env::current_exe().ok();- let host = json!({ "data": data, "downloads": downloads, "rustyfiles": me });+ let host = host_file(settings, &data, me.as_deref());let _ = std::fs::write(dir.join("host.json"), serde_json::to_vec_pretty(&host).unwrap_or_default());let origins: Vec<String> = EXTENSION_IDS.iter().map(|id| format!("chrome-extension://{id}/")).collect();let manifest = json!({ "name": HOST_NAME, "description": "HyperDownload, the download manager of rustyfiles", "path": exe, "type": "stdio", "allowed_origins": origins });@@ -634,6 +650,23 @@ pub fn download_source(source: Source, dir: PathBuf, cx: &mut gpui_kit::App) {mod tests {use super::*;+ /// HyperDownload issue 1: the host file says the folder the settings HAVE, not the one a file read back a moment later had.+ #[test]+ fn the_host_file_names_the_folder_chosen_in_settings() {+ let data = Path::new("data-folder");+ let mut s = crate::settings::Settings::default();+ s.hd_downloads = "chosen-folder".into();+ let host = host_file(&s, data, Some(Path::new("rustyfiles.exe")));+ assert_eq!(host["downloads"], json!("chosen-folder"));+ assert_eq!(host["data"], json!("data-folder"));+ assert_eq!(host["rustyfiles"], json!("rustyfiles.exe"));+ // none chosen: Windows' Downloads folder (or the data folder where Windows names none), never an empty text+ s.hd_downloads = " ".into();+ let host = host_file(&s, data, None);+ assert!(host["downloads"].as_str().is_some_and(|d| !d.trim().is_empty()));+ assert_ne!(host["downloads"], json!("chosen-folder"));+ }+#[test]fn a_status_is_read_from_arias_strings() {let v = json!({ "status": "active", "totalLength": "1000", "completedLength": "250", "downloadSpeed": "50",diff --git a/crates/rf-app/src/settings_view.rs b/crates/rf-app/src/settings_view.rsindex a6a6af73..d09078ae 100644--- a/crates/rf-app/src/settings_view.rs+++ b/crates/rf-app/src/settings_view.rs@@ -4415,7 +4415,9 @@ fn advanced(p: &Palette, s: &Settings, cx: &mut App) -> Vec<AnyElement> {Some(t!("Uyarılar ve hatalar rustyfiles.log dosyasına yazılır (en çok 1 MB; dolunca eskisi .old olur). Bir sorunu bildirirken eklenebilir.")),button("log-open", p, t!("Klasörde göster"), |_, cx| {if let Some(path) = crate::logfile::path() {- crate::workspace::route_ipc(format!("{}{}", crate::workspace::SELECT_PREFIX, path.display()), cx);+ // (after this window's own update: a window cannot be given a tab while it handles the click, and a second+ // window was made instead: see `workspace::show_in_folder_from`)+ cx.defer(move |cx| crate::workspace::route_ipc(format!("{}{}", crate::workspace::SELECT_TAB_PREFIX, path.display()), cx));}}),),diff --git a/crates/rf-app/src/transfer_view.rs b/crates/rf-app/src/transfer_view.rsindex 80c12faf..c3f645e2 100644--- a/crates/rf-app/src/transfer_view.rs+++ b/crates/rf-app/src/transfer_view.rs@@ -557,7 +557,11 @@ fn card(ops: &Entity<Ops>, p: &Palette, v: &OpView) -> Stateful<Div> {}Stage::Result(Outcome::Done) => {let open = v.open_dest.clone().map(|dir| {- text_button(("card-open", id), p, t!("Hedefi aç"), false, move |_, cx| crate::workspace::route_ipc(dir.to_string_lossy().into_owned(), cx))+ text_button(("card-open", id), p, t!("Hedefi aç"), false, move |_, cx| {+ // (after this window's own update: see `workspace::show_in_folder_from`)+ let dir = dir.clone();+ cx.defer(move |cx| crate::workspace::route_ipc(dir.to_string_lossy().into_owned(), cx));+ })});let undo = v.can_undo.then(|| {let ops = ops.clone();diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rsindex 4b4256f5..a79bb9ab 100644--- a/crates/rf-app/src/workspace.rs+++ b/crates/rf-app/src/workspace.rs@@ -837,6 +837,28 @@ pub fn route_ipc_shown(msg: String, cx: &mut App) -> bool {made}+/// A file shown in its folder, selected, in a new tab of the window the request came from (`from`). When that window is no file+/// manager window (the Downloads window of its own), a window is picked as for any request ([`route_ipc`]). Call it OUTSIDE every+/// window's update (deferred).+///+/// WHY (HyperDownload issue 1, twice: "Show in folder still opens a tab in a new window instead of opening a tab in the current+/// window"). The button's handler runs inside its own window's update, and `route_ipc` updates the window it picks: the very+/// window that was being updated could not be updated again, the loop found no other one, and a new window was made. So with one+/// window open, which is the usual case, the button always opened a second one.+pub fn show_in_folder_from(from: AnyWindowHandle, file: &Path, cx: &mut App) {+ let (loc, select) = parse_launch(&format!("{SELECT_PREFIX}{}", file.display()));+ let here = cx+ .try_global::<OpenWorkspaces>()+ .and_then(|g| g.0.iter().find(|(h, _)| *h == from).and_then(|(_, ws)| ws.upgrade()))+ .filter(|ws| ws.read(cx).picker.is_none());+ if let Some(ws) = here+ && from.update(cx, |_, window, cx| ws.update(cx, |w, cx| w.open_tab_selecting(loc, select, window, cx))).is_ok()+ {+ return;+ }+ route_ipc(format!("{SELECT_TAB_PREFIX}{}", file.display()), cx);+}+/// Puts a search at the front of the remembered ones (once, whatever its case; ten are kept).fn remember_search(history: &mut Vec<String>, q: &str) {let q = q.trim();