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
Finished videos and galleries are marked as downloaded beside the window (#510) (#515)
Ahmed Nefzaouicc7def8ba50b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8ffee570..ddc4bc7d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see### Fixed+- The window no longer freezes when a video or a gallery finishes: marking its files as downloaded from the web, which can wait on the disk and the antivirus for a while with a big video, now happens beside the window ([#510](https://github.com/anefzaoui/misterdownloadmanager/issues/510)).- Linux: **View → Dark Mode support** turns dark on window managers such as Hyprland and sway when only GNOME's setting says so (`gsettings set org.gnome.desktop.interface color-scheme prefer-dark`), as it did when a desktop portal answered ([#324](https://github.com/anefzaoui/misterdownloadmanager/issues/324)).- Dark mode no longer draws a bright white line under the menu bar, across the whole window, in the Classic and Native themes ([#379](https://github.com/anefzaoui/misterdownloadmanager/issues/379)).### Addeddiff --git a/ROADMAP.md b/ROADMAP.mdindex efeb799c..c97ecbc6 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -519,6 +519,8 @@ These ship in a later version, when they're ready.### Bugs being looked into+- 🔄 A freeze when a video finishes, while its file is marked as downloaded from the web+ ([#510](https://github.com/anefzaoui/misterdownloadmanager/issues/510)): fix in review- 🔄 Linux: Dark Mode support on window managers such as Hyprland and sway, which often have nodesktop portal to say dark or light ([#324](https://github.com/anefzaoui/misterdownloadmanager/issues/324)): fix in review- 🔄 A bright white line under the menu bar in dark modediff --git a/crates/app/src/app.rs b/crates/app/src/app.rsindex 9c4fff2d..1195f594 100644--- a/crates/app/src/app.rs+++ b/crates/app/src/app.rs@@ -729,6 +729,29 @@ fn page_data_for(link: &str, page: Option<&str>, data: Option<&str>) -> Option<S.flatten()}+/// Marks finished files (a video's and its subtitles, a gallery's pictures) as downloaded from the+/// web, as `mark_hook` does for the engine's, on a thread of their own: writing the mark has the+/// antivirus read the whole file again, and on a big video that kept the window waiting (#510). A+/// file moved or removed meanwhile is left alone: marking its old path would create an empty+/// file there.+pub(crate) fn mark_finished(+ files: Vec<std::path::PathBuf>,+ url: String,+ referrer: Option<String>,+) -> Option<std::thread::JoinHandle<()>> {+ std::thread::Builder::new()+ .name("mark-downloaded".into())+ .spawn(move || {+ for f in files.iter().filter(|f| f.is_file()) {+ #[cfg(windows)]+ crate::win32::mark_downloaded(f, &url, referrer.as_deref());+ #[cfg(unix)]+ crate::unix::mark_downloaded(f, &url, referrer.as_deref());+ }+ })+ .ok()+}+/// Marks each file the engine starts writing as downloaded from the web (Mark-of-the-Web, macOS'/// quarantine: win32 / unix `mark_downloaded`), as browsers mark theirs. Only http(s) addresses/// (an FTP address may carry its login).@@ -9213,3 +9236,33 @@ mod window_thread_tests {assert!(!dest.exists());}}++#[cfg(test)]+mod mark_finished_tests {+ /// #510: finished files are marked away from the window's thread; a file gone from its path+ /// meanwhile (moved, deleted) isn't created again by the mark.+ #[test]+ fn a_finished_file_is_marked_and_a_gone_one_is_not_created() {+ let dir = tempfile::tempdir().unwrap();+ let here = dir.path().join("video.mp4");+ std::fs::write(&here, b"x").unwrap();+ let gone = dir.path().join("moved.mp4");+ super::mark_finished(+ vec![here.clone(), gone.clone()],+ "https://videos.test/v".into(),+ None,+ )+ .unwrap()+ .join()+ .unwrap();+ assert!(!gone.exists(), "a moved file's old path stays empty");+ #[cfg(windows)]+ {+ let mut stream = here.as_os_str().to_owned();+ stream.push(":Zone.Identifier");+ let zone = std::fs::read_to_string(stream).unwrap();+ assert!(zone.contains("ZoneId=3"), "{zone}");+ assert!(zone.contains("HostUrl=https://videos.test/v"), "{zone}");+ }+ }+}diff --git a/crates/app/src/model.rs b/crates/app/src/model.rsindex dcb8d2e5..69cbcd46 100644--- a/crates/app/src/model.rs+++ b/crates/app/src/model.rs@@ -815,20 +815,11 @@ impl Item {.map(|p| sub_notice(p, site)).collect();let side = done.side_files;- for f in s.file.iter().chain(side.iter()) {- #[cfg(windows)]- crate::win32::mark_downloaded(- f,- url.as_str(),- self.context.referer.as_deref(),- );- #[cfg(unix)]- crate::unix::mark_downloaded(- f,- url.as_str(),- self.context.referer.as_deref(),- );- }+ crate::app::mark_finished(+ s.file.iter().chain(side.iter()).cloned().collect(),+ url.to_string(),+ self.context.referer.clone(),+ );}// A gallery's files (#58), each marked as downloaded from the web, as above.if status == Status::Complete@@ -838,12 +829,7 @@ impl Item {}) = &self.live&& matches!(url.scheme(), "http" | "https"){- for f in &job.saved() {- #[cfg(windows)]- crate::win32::mark_downloaded(f, url.as_str(), None);- #[cfg(unix)]- crate::unix::mark_downloaded(f, url.as_str(), None);- }+ crate::app::mark_finished(job.saved(), url.to_string(), None);}for n in ¬ices {self.note(n.clone());