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
Add-ons: HyperDownload's browser extension is put ready from Settings
gelenmedya534bd3e17887
diff --git a/crates/rf-app/src/addons.rs b/crates/rf-app/src/addons.rsindex 1064edfd..43bd061b 100644--- a/crates/rf-app/src/addons.rs+++ b/crates/rf-app/src/addons.rs@@ -36,6 +36,10 @@ pub struct AddonInfo {/// One per processor: "x64", "arm64".#[serde(default)]pub files: std::collections::HashMap<String, FileRef>,+ /// The add-on's browser extension for this version: a zip with the extension's files at its top (HyperDownload). It is loaded+ /// by hand in the browser until it is in the stores; Settings puts the folder ready ([`install_extension`]).+ #[serde(default)]+ pub extension: Option<FileRef>,}#[derive(Clone, Debug, Deserialize)]@@ -83,6 +87,69 @@ pub fn installed(id: &str) -> Option<Installed> {d.join(&i.version).join(&i.exe).is_file().then_some(i)}+/// The folder name of an add-on's browser extension, beside its version folders.+const EXTENSION_DIR: &str = "extension";++/// Where the browser extension of `id` is unpacked. ONE place for every version: a browser remembers an extension loaded by hand+/// by its folder, so the folder must not move when the add-on is updated.+pub fn extension_dir(id: &str) -> Option<PathBuf> {+ dir_of(id).map(|d| d.join(EXTENSION_DIR))+}++/// The version of the extension unpacked in `dir` (its manifest's "version"), when there is one.+fn extension_version_in(dir: &Path) -> Option<String> {+ let manifest: serde_json::Value = serde_json::from_slice(&std::fs::read(dir.join(EXTENSION_DIR).join("manifest.json")).ok()?).ok()?;+ manifest.get("version")?.as_str().map(str::to_string)+}++/// The version of `id`'s extension that is unpacked, when one is.+pub fn extension_version(id: &str) -> Option<String> {+ extension_version_in(&dir_of(id)?)+}++/// Brings `file` (the extension's zip), checks its SHA-256 and unpacks it into `dir`'s extension folder, in place of what was+/// there. Gives the folder. A zip that is not the listed one, or that has no manifest.json at its top, changes nothing.+fn unpack_extension(dir: &Path, file: &FileRef, cancelled: &dyn Fn() -> bool) -> Result<PathBuf, String> {+ std::fs::create_dir_all(dir).map_err(|e| e.to_string())?;+ let zip = dir.join(".extension.zip");+ let sha = match download(&file.url, &zip, file.size, &|_| {}, cancelled) {+ Ok(s) => s,+ Err(e) => {+ let _ = std::fs::remove_file(&zip);+ return Err(e);+ }+ };+ if !sha.eq_ignore_ascii_case(file.sha256.trim()) {+ let _ = std::fs::remove_file(&zip);+ return Err("the download is not the file the list names (its SHA-256 differs): it was not unpacked".into());+ }+ let staging = dir.join(".extension.tmp");+ let _ = std::fs::remove_dir_all(&staging);+ let unpacked = rf_archive::extract(&zip, &staging, &mut |_| {}, cancelled);+ let _ = std::fs::remove_file(&zip);+ if let Err(e) = unpacked {+ let _ = std::fs::remove_dir_all(&staging);+ return Err(e.to_string());+ }+ if !staging.join("manifest.json").is_file() {+ let _ = std::fs::remove_dir_all(&staging);+ return Err("manifest.json is not at the top of the extension's zip".into());+ }+ let target = dir.join(EXTENSION_DIR);+ if target.exists() {+ std::fs::remove_dir_all(&target).map_err(|e| format!("{}: {e}", target.display()))?;+ }+ std::fs::rename(&staging, &target).map_err(|e| e.to_string())?;+ Ok(target)+}++/// Puts the browser extension of `info` ready in its folder ([`extension_dir`]): downloaded, checked, unpacked. Blocking.+pub fn install_extension(info: &AddonInfo, cancelled: &dyn Fn() -> bool) -> Result<PathBuf, String> {+ let file = info.extension.as_ref().ok_or_else(|| format!("{} has no browser extension in the list", info.name))?;+ let dir = dir_of(&info.id).ok_or("no folder for add-ons")?;+ unpack_extension(&dir, file, cancelled)+}+/// The installed program of `id`.pub fn program(id: &str) -> Option<PathBuf> {let i = installed(id)?;@@ -297,11 +364,19 @@ pub fn install(info: &AddonInfo, progress: &dyn Fn(u64, u64), cancelled: &dyn Fnif let Ok(rd) = std::fs::read_dir(&dir) {for e in rd.flatten() {let n = e.file_name().to_string_lossy().into_owned();- if e.path().is_dir() && n != info.version && !n.starts_with('.') {+ // (the browser extension's folder is no version: it stays where the browser knows it)+ if e.path().is_dir() && n != info.version && n != EXTENSION_DIR && !n.starts_with('.') {let _ = std::fs::remove_dir_all(e.path());}}}+ // an extension put ready before goes with the program's version (in the same folder, so the browser keeps it)+ if extension_version_in(&dir).is_some()+ && info.extension.is_some()+ && let Err(e) = install_extension(info, cancelled)+ {+ log::warn!("add-on {}: its browser extension was not brought up to {}: {e}", info.id, info.version);+ }CHANGES.fetch_add(1, std::sync::atomic::Ordering::Relaxed);Ok(now)}@@ -375,6 +450,47 @@ mod tests {(url, hits)}+ /// The browser extension's zip is checked, unpacked into ONE folder that stays, and a second one replaces the first in place.+ #[test]+ fn the_extension_is_unpacked_into_a_folder_that_stays() {+ let base = scratch_file("extension");+ let _ = std::fs::remove_dir_all(&base);+ let make = |version: &str| -> FileRef {+ let src = base.join(format!("src-{version}"));+ std::fs::create_dir_all(&src).unwrap();+ std::fs::write(src.join("manifest.json"), format!("{{\"manifest_version\": 3, \"version\": \"{version}\"}}")).unwrap();+ std::fs::write(src.join("background.js"), b"// nothing").unwrap();+ let zip = base.join(format!("ext-{version}.zip"));+ rf_archive::compress(&[src.join("manifest.json"), src.join("background.js")], &zip, rf_archive::Format::Zip, 5, &mut |_| {}, &|| false).unwrap();+ let bytes = std::fs::read(&zip).unwrap();+ FileRef { url: zip.to_string_lossy().into_owned(), sha256: sha_of(&bytes), size: bytes.len() as u64 }+ };+ let dir = base.join("addon");+ let first = unpack_extension(&dir, &make("0.1.0"), &|| false).unwrap();+ assert_eq!(first, dir.join("extension"));+ assert!(first.join("background.js").is_file());+ assert_eq!(extension_version_in(&dir).as_deref(), Some("0.1.0"));+ // the next version lands in the same folder+ let second = unpack_extension(&dir, &make("0.2.0"), &|| false).unwrap();+ assert_eq!(second, first);+ assert_eq!(extension_version_in(&dir).as_deref(), Some("0.2.0"));+ // a zip that is not the listed one changes nothing+ let mut wrong = make("0.3.0");+ wrong.sha256 = "00".repeat(32);+ assert!(unpack_extension(&dir, &wrong, &|| false).is_err());+ assert_eq!(extension_version_in(&dir).as_deref(), Some("0.2.0"));+ assert!(!dir.join(".extension.zip").exists() && !dir.join(".extension.tmp").exists());+ let _ = std::fs::remove_dir_all(&base);+ }++ #[test]+ fn the_list_may_name_an_extension_and_an_older_list_has_none() {+ let with: Manifest = serde_json::from_str(r#"{"addons":[{"id":"x","name":"X","version":"1.0.0","license":"MIT","source":"","files":{},"extension":{"url":"https://example.com/e.zip","sha256":"ab"}}]}"#).unwrap();+ assert_eq!(with.addons[0].extension.as_ref().map(|e| e.url.as_str()), Some("https://example.com/e.zip"));+ let without: Manifest = serde_json::from_str(r#"{"addons":[{"id":"x","name":"X","version":"1.0.0","license":"MIT","source":"","files":{}}]}"#).unwrap();+ assert!(without.addons[0].extension.is_none());+ }+fn sha_of(bytes: &[u8]) -> String {Sha256::digest(bytes).iter().map(|b| format!("{b:02x}")).collect()}@@ -461,7 +577,7 @@ mod tests {let zip = tmp.join("demo.zip");rf_archive::compress(&[src.join("demo.exe")], &zip, rf_archive::Format::Zip, 5, &mut |_| {}, &|| false).unwrap();let sha: String = Sha256::digest(std::fs::read(&zip).unwrap()).iter().map(|b| format!("{b:02x}")).collect();- let mut info = AddonInfo { id: "demo".into(), name: "Demo".into(), version: "0.1.0".into(), license: "MIT".into(), source: String::new(), files: Default::default() };+ let mut info = AddonInfo { id: "demo".into(), name: "Demo".into(), version: "0.1.0".into(), license: "MIT".into(), source: String::new(), extension: None, files: Default::default() };info.files.insert(arch().into(), FileRef { url: zip.display().to_string(), sha256: "00".into(), size: 0 });let err = install(&info, &|_, _| {}, &|| false).unwrap_err();assert!(err.contains("SHA-256"), "{err}");diff --git a/crates/rf-app/src/addons_page.rs b/crates/rf-app/src/addons_page.rsindex 32c85025..233f04e5 100644--- a/crates/rf-app/src/addons_page.rs+++ b/crates/rf-app/src/addons_page.rs@@ -178,6 +178,87 @@ fn download_folder_card(p: &Palette, cx: &mut App) -> AnyElement {)}+/// The key of an add-on's browser extension in the page's state (what is busy, what went wrong).+fn extension_key(id: &str) -> String {+ format!("{id}-extension")+}++/// HyperDownload's browser extension, which is not in the browsers' stores yet and so is loaded by hand. What can be done for+/// the user is done here: the extension's folder is put ready (downloaded, checked against the list's SHA-256, in a place that+/// stays), its path is copied, and the browser is opened. The rest is theirs there (the extensions page, Developer mode, "Load+/// unpacked", paste): a browser lets no program add an extension for it, and Chrome does not even open `chrome://extensions`+/// when it is named on its command line (tried 2026-12-05: a new tab came up instead), so the card says the address to type.+///+/// WHY (Discord, 2026-12-04: "i can't load the unpacked extension", after choosing the repository's folder instead of the one+/// inside it; the user: "there is no way to install the extension in HyperDownload's settings").+fn extension_card(info: &AddonInfo, p: &Palette, cx: &mut App) -> Option<AnyElement> {+ info.extension.as_ref()?;+ let key = extension_key(&info.id);+ let busy = state(cx).busy.contains_key(&key);+ let error = state(cx).errors.get(&key).cloned();+ let mut desc = t!("Tarayıcının indirmelerini HyperDownload'a verir. Henüz mağazalarda değil, elle yüklenir: tarayıcınızın düğmesine basın (klasör hazırlanır, yolu panoya kopyalanır, tarayıcı açılır). Tarayıcıda adres çubuğuna chrome://extensions yazın (Edge: edge://extensions, Brave: brave://extensions), Geliştirici modunu açın, \"Paketlenmemiş öğe yükle\"ye basın ve klasör kutusuna yolu yapıştırın.").to_string();+ if let (Some(v), Some(dir)) = (addons::extension_version(&info.id), addons::extension_dir(&info.id)) {+ desc.push('\n');+ desc.push_str(&format!("{} {v} · {}", t!("Hazır olan sürüm:"), dir.display()));+ }+ if let Some(e) = &error {+ desc.push('\n');+ desc.push_str(e);+ }+ let browsers = crate::hyperdownload::browsers();+ if browsers.is_empty() {+ desc.push('\n');+ desc.push_str(t!("Chrome, Edge ya da Brave bulunamadı."));+ }+ let control: AnyElement = if busy {+ div().text_sm().text_color(p.text_secondary).child(t!("Hazırlanıyor…")).into_any_element()+ } else {+ let mut row = h_flex().gap_2();+ for b in browsers {+ let (info, exe) = (info.clone(), b.exe);+ row = row.child(button(SharedString::from(format!("hd-extension-{}", b.name)), p, b.name, move |_, cx| load_extension(info.clone(), exe.clone(), cx)));+ }+ row.into_any_element()+ };+ Some(card(p, L::Puzzle, t!("Tarayıcı uzantısı"), Some(&desc), control))+}++/// A browser's button of [`extension_card`]: the folder ready (as it is when it already is this version's), its path on the+/// clipboard, the browser open.+fn load_extension(info: AddonInfo, exe: std::path::PathBuf, cx: &mut App) {+ let key = extension_key(&info.id);+ let st = state(cx);+ st.errors.remove(&key);+ st.busy.insert(key.clone(), Busy { done: Arc::new(AtomicU64::new(0)), total: 0, cancel: Arc::new(AtomicBool::new(false)) });+ cx.refresh_windows();+ cx.spawn(async move |cx| {+ let got = cx+ .background_spawn(async move {+ match (addons::extension_version(&info.id), addons::extension_dir(&info.id)) {+ (Some(v), Some(dir)) if v == info.version => Ok(dir),+ _ => addons::install_extension(&info, &|| false),+ }+ })+ .await;+ cx.update(|cx| {+ let failed = match got {+ Ok(dir) => {+ cx.write_to_clipboard(ClipboardItem::new_string(dir.to_string_lossy().into_owned()));+ std::process::Command::new(&exe).spawn().err().map(|e| format!("{}: {e}", exe.display()))+ }+ Err(e) => Some(e),+ };+ let st = cx.global_mut::<State>();+ st.busy.remove(&key);+ if let Some(e) = failed {+ st.errors.insert(key, e);+ }+ cx.refresh_windows();+ });+ })+ .detach();+}+pub fn page(p: &Palette, cx: &mut App) -> Vec<AnyElement> {if state(cx).manifest.is_none() {load(cx);@@ -270,6 +351,7 @@ pub fn page(p: &Palette, cx: &mut App) -> Vec<AnyElement> {out.push(card(p, L::Download, &info.name, Some(&desc), control));if id == crate::hyperdownload::ID && have.is_some() {out.push(download_folder_card(p, cx));+ out.extend(extension_card(&info, p, cx));}let source = info.source.clone();if !source.is_empty() {diff --git a/crates/rf-app/src/hyperdownload.rs b/crates/rf-app/src/hyperdownload.rsindex 5d5292f7..02251dbd 100644--- a/crates/rf-app/src/hyperdownload.rs+++ b/crates/rf-app/src/hyperdownload.rs@@ -97,6 +97,29 @@ pub fn unregister_host() {}}+/// A browser the extension can be loaded into by hand: its name and its program.+pub struct Browser {+ pub name: &'static str,+ pub exe: PathBuf,+}++/// The Chromium browsers installed here (the ones the host is registered for and Windows knows a program path of). Firefox is+/// not among them: it takes the extension as a package of its own, another way (the add-on's README).+pub fn browsers() -> Vec<Browser> {+ const KNOWN: [(&str, &str); 3] = [("Chrome", "chrome.exe"), ("Edge", "msedge.exe"), ("Brave", "brave.exe")];+ KNOWN.iter().filter_map(|&(name, exe)| app_path(exe).map(|exe| Browser { name, exe })).collect()+}++/// A program's path from Windows' "App Paths" (the user's entry first, then the machine's), when the file is there.+fn app_path(exe: &str) -> Option<PathBuf> {+ let key = format!(r"Software\Microsoft\Windows\CurrentVersion\App Paths\{exe}");+ [windows_registry::CURRENT_USER, windows_registry::LOCAL_MACHINE]+ .iter()+ .find_map(|root| root.open(&key).ok()?.get_string("").ok())+ .map(|p| PathBuf::from(p.trim().trim_matches('"')))+ .filter(|p| p.is_file())+}+/// Shows a download HyperDownload already has (handed over by the browser) as a card, into the Downloads folder.pub fn follow(gid: String, cx: &mut gpui_kit::App) {let dir = download_folder(cx.global::<crate::settings::Settings>()).unwrap_or_default();@@ -661,7 +684,7 @@ mod e2e {// the add-on, installed as the Add-ons page does ituse sha2::Digest;let sha: String = sha2::Sha256::digest(std::fs::read(&zip).unwrap()).iter().map(|b| format!("{b:02x}")).collect();- let mut info = crate::addons::AddonInfo { id: ID.into(), name: "HyperDownload".into(), version: "0.1.0".into(), license: "MIT".into(), source: String::new(), files: Default::default() };+ let mut info = crate::addons::AddonInfo { id: ID.into(), name: "HyperDownload".into(), version: "0.1.0".into(), license: "MIT".into(), source: String::new(), extension: None, files: Default::default() };info.files.insert(crate::addons::arch().into(), crate::addons::FileRef { url: zip.display().to_string(), sha256: sha, size: 0 });crate::addons::install(&info, &|_, _| {}, &|| false).unwrap();// a server: 3 MB with rangesdiff --git a/crates/rf-app/src/i18n_en.rs b/crates/rf-app/src/i18n_en.rsindex f6471ff5..a944a40e 100644--- a/crates/rf-app/src/i18n_en.rs+++ b/crates/rf-app/src/i18n_en.rs@@ -421,6 +421,10 @@ pub const EN: &[(&str, &str)] = &[("Sıkıştır", "Compress"),("Dönüştür", "Convert"),("Dönüştürülüyor:", "Converting:"),+ ("Tarayıcı uzantısı", "Browser extension"),+ ("Tarayıcının indirmelerini HyperDownload'a verir. Henüz mağazalarda değil, elle yüklenir: tarayıcınızın düğmesine basın (klasör hazırlanır, yolu panoya kopyalanır, tarayıcı açılır). Tarayıcıda adres çubuğuna chrome://extensions yazın (Edge: edge://extensions, Brave: brave://extensions), Geliştirici modunu açın, \"Paketlenmemiş öğe yükle\"ye basın ve klasör kutusuna yolu yapıştırın.", "Hands the browser's downloads to HyperDownload. It is not in the stores yet and is loaded by hand: press your browser's button (the folder is put ready, its path is copied to the clipboard, the browser opens). In the browser type chrome://extensions into the address bar (Edge: edge://extensions, Brave: brave://extensions), switch on Developer mode, press \"Load unpacked\" and paste the path into the folder box."),+ ("Hazır olan sürüm:", "Version put ready:"),+ ("Chrome, Edge ya da Brave bulunamadı.", "Chrome, Edge or Brave was not found."),("Shift+tık: seçenekler", "Shift+click: options"),("{format} biçimine dönüştür", "Convert to {format}"),("En uzun kenar", "Longest side"),