misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux
Rust bittorrent-clientdebriddownload-acceleratordownload-managerdownloadmanagereguifile-downloadergallery-dlidmidm-alternativeinternet-download-managerm3u8-downloadermagnetplaylist-downloaderreal-debridrusttorrent-clientvideo-downloaderyoutube-downloaderyt-dlp
Add URL: Use authorization shows the Sites Logins entry for the address (#511) (#521)
Ahmed Nefzaoui4cfc940ced12
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 58a2b9a4..26e7dfbb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see### Fixed+- **Enter new address to download**: an address with a login in **Options → Sites Logins** shows that login under **Use authorization** (ticked, the user name and the password), the one the download uses; it was used but the box stayed empty. A login typed there still goes first ([#511](https://github.com/anefzaoui/misterdownloadmanager/issues/511)).- The window no longer waits for the disk to write MDM's log or to save the RSS feeds: while Windows held every write on the disk to make a snapshot of it (a restore point or a backup), the window could stop answering until the writes were let go. Both are now written beside the window, as the download list already was (part of [#513](https://github.com/anefzaoui/misterdownloadmanager/issues/513)).- Windows: video and gallery look-ups no longer fail with "[WinError 448] The path cannot be traversed because it contains an untrusted mount point" when a folder on PATH goes through a junction Windows won't let yt-dlp cross (one an app installed for itself, Codex's for example): yt-dlp, gallery-dl and the ffmpeg they start get that folder's real place instead, and no folder that can't be opened ([#508](https://github.com/anefzaoui/misterdownloadmanager/issues/508)).- **Download video** from Dailymotion's player embedded in another site: the look-up no longer sends that site as the Referer, which Dailymotion refused with 403, so its formats are found as with the video's own address ([#359](https://github.com/anefzaoui/misterdownloadmanager/issues/359)).diff --git a/ROADMAP.md b/ROADMAP.mdindex c81db95e..24a6eafb 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -520,6 +520,9 @@ These ship in a later version, when they're ready.### Bugs being looked into+- 🔄 Add URL's **Use authorization** empty for an address with a login in Options → Sites+ Logins, though the download used it+ ([#511](https://github.com/anefzaoui/misterdownloadmanager/issues/511)): fix in review- 🔄 Two tests that fail now and then on busy CI runners([#518](https://github.com/anefzaoui/misterdownloadmanager/issues/518)): the slow-flush one in review- 🔄 The window not answering for a few seconds while Windows makes a snapshot of the diskdiff --git a/crates/app/src/app.rs b/crates/app/src/app.rsindex f6114d43..1659a811 100644--- a/crates/app/src/app.rs+++ b/crates/app/src/app.rs@@ -8085,7 +8085,7 @@ impl App {}}if let Some(d) = &mut self.add_url {- let out = d.show(ctx);+ let out = d.show(ctx, |url| self.settings.site_login(url));// Every address that goes on is remembered for the Address drop list.if let Outcome::Done(new) = &out {crate::settings::remember(&mut self.settings.url_history, new.url.as_str());diff --git a/crates/app/src/dialogs.rs b/crates/app/src/dialogs.rsindex c66cacd0..869b7e78 100644--- a/crates/app/src/dialogs.rs+++ b/crates/app/src/dialogs.rs@@ -596,6 +596,10 @@ pub struct AddUrl {/// The addresses entered before, newest first (the Address drop list).history: Vec<String>,list_open: bool,+ /// The address Options → Sites Logins was last looked up for, and the login it gave+ /// (#511): "Use authorization" shows it while the box is left as it was filled.+ looked_up: String,+ filled: Option<(String, String)>,}pub struct NewUrl {@@ -620,7 +624,44 @@ impl AddUrl {}}- pub fn show(&mut self, ctx: &egui::Context) -> Outcome<NewUrl> {+ /// "Use authorization" shows the Sites Logins entry the download will use for the address+ /// (#511): `site_login` is that same match (`Settings::site_login`). A login typed or+ /// changed in the box is left alone; one filled from Options follows the address.+ fn follow_site_login(&mut self, site_login: impl Fn(&Url) -> Option<(String, String)>) {+ if self.looked_up == self.address {+ return;+ }+ self.looked_up.clone_from(&self.address);+ let found = crate::model::parse_address(&self.address)+ .ok()+ .and_then(|u| site_login(&u));+ if found == self.filled {+ return;+ }+ let as_filled = match &self.filled {+ Some((user, pass)) => self.auth && self.login == *user && self.password == *pass,+ None => !self.auth && self.login.is_empty() && self.password.is_empty(),+ };+ if as_filled {+ self.auth = found.is_some();+ (self.login, self.password) = found.clone().unwrap_or_default();+ }+ self.filled = found;+ }++ /// The login OK hands on: none while the box shows the Sites Logins entry as it was filled,+ /// so the download keeps following Options, as it does without one.+ fn typed_login(&self) -> Option<(String, String)> {+ let own = (self.login.clone(), self.password.clone());+ (self.auth && self.filled.as_ref() != Some(&own)).then_some(own)+ }++ pub fn show(+ &mut self,+ ctx: &egui::Context,+ site_login: impl Fn(&Url) -> Option<(String, String)>,+ ) -> Outcome<NewUrl> {+ self.follow_site_login(site_login);window(ctx,"add-url",@@ -780,9 +821,7 @@ impl AddUrl {Ok(url) if mdm_engine::supported(&url) || url.scheme() == "magnet" => {return Outcome::Done(NewUrl {url,- login: self- .auth- .then(|| (self.login.clone(), self.password.clone())),+ login: self.typed_login(),});}_ => self.error = Some(crate::i18n::t("Invalid address").into()),@@ -3179,7 +3218,7 @@ mod tests {};for _ in 0..6 {let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {- let _ = dlg.show(ui.ctx());+ let _ = dlg.show(ui.ctx(), |_| None);});out.textures_delta.clear();}@@ -3190,6 +3229,55 @@ mod tests {.expect("Add URL hung");}+ /// #511: an address with an Options → Sites Logins entry shows that login in "Use+ /// authorization" (the match the download uses), follows the address while left as filled,+ /// and keeps a login typed in the box. OK hands on only a login of the user's own.+ #[test]+ fn add_url_shows_the_sites_logins_entry_for_its_address() {+ // A made-up login; asserts don't print it.+ const PASS: &str = "dummy-pass";+ let settings = crate::settings::Settings {+ site_logins: vec![(+ "files.example.com/private".into(),+ "demo".into(),+ PASS.into(),+ )],+ ..Default::default()+ };+ let ctx = egui::Context::default();+ let mut dlg = AddUrl {+ address: "https://files.example.com/private/x.zip".into(),+ ..AddUrl::default()+ };+ let pass = |dlg: &mut AddUrl| {+ let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {+ let _ = dlg.show(ui.ctx(), |u| settings.site_login(u));+ });+ out.textures_delta.clear();+ };+ pass(&mut dlg);+ assert!(dlg.auth, "Use authorization is ticked");+ assert_eq!(dlg.login, "demo");+ assert!(dlg.password == PASS, "the password is the saved one");+ assert!(dlg.typed_login().is_none(), "the download follows Options");++ // Another address: the box filled from Options empties again.+ dlg.address = "https://files.example.com/public/x.zip".into();+ pass(&mut dlg);+ assert!(!dlg.auth);+ assert!(dlg.login.is_empty() && dlg.password.is_empty());++ // Back to the address, then a login typed over it: kept, and handed on.+ dlg.address = "https://files.example.com/private/y.zip".into();+ pass(&mut dlg);+ assert!(dlg.auth && dlg.login == "demo");+ dlg.login = "someone".into();+ dlg.address = "https://files.example.com/public/y.zip".into();+ pass(&mut dlg);+ assert!(dlg.auth && dlg.login == "someone", "a typed login stays");+ assert_eq!(dlg.typed_login().map(|l| l.0).as_deref(), Some("someone"));+ }+/// #207: a dialog closed by the window manager (its title bar's ×) is painted in the pass/// that closes it. The dialog's window is rendered as eframe renders it: its own pass, after/// the window was cleared to transparent black. A pass that painted nothing left the window