Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

A finished file that was moved or deleted is no longer a duplicate (#371)

Ahmed Nefzaouida019249c9de
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f2589c7b..29fa8dcc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,12 @@
Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
`.github/workflows/release.yml`).
+## [Unreleased]
+
+### Fixed
+
+- Adding a link again after its finished file was moved or deleted starts a new download, instead of asking about a duplicate that isn't there ([#342](https://github.com/anefzaoui/misterdownloadmanager/issues/342)).
+
## [0.5.1] - 2026-11-08
YouTube fixes for the Download video button, and the button in Chrome, Edge and Brave.
diff --git a/ROADMAP.md b/ROADMAP.md
index 366401da..8e84755e 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -447,6 +447,8 @@ These ship in a later version, when they're ready.
### Bugs being looked into
+- 🔄 A duplicate prompt for a finished file that is gone
+ ([#342](https://github.com/anefzaoui/misterdownloadmanager/issues/342)): fix in review
- 🔍 A 10-second freeze of the window after a night left open
([#304](https://github.com/anefzaoui/misterdownloadmanager/issues/304)): most likely the
computer waking from sleep; waiting on the reporter's full report
diff --git a/crates/app/src/app.rs b/crates/app/src/app.rs
index da8f3933..43f78907 100644
--- a/crates/app/src/app.rs
+++ b/crates/app/src/app.rs
@@ -6686,14 +6686,21 @@ impl App {
if std::mem::take(&mut self.duplicate_cleared) {
return true;
}
- let Some((dup, name)) = self
- .items
- .iter()
- .find(|i| i.url == *url)
- .map(|i| (i.id, i.file_name.clone()))
- else {
+ let Some((dup, name, gone)) = self.items.iter().find(|i| i.url == *url).map(|i| {
+ (
+ i.id,
+ i.file_name.clone(),
+ model::finished_file_gone(i.status, &i.dest),
+ )
+ }) else {
return true;
};
+ // #342: its file was moved or deleted, so there is nothing to duplicate: the old row
+ // goes and this is an ordinary new download.
+ if gone {
+ self.overwrite(dup);
+ return true;
+ }
match self.settings.duplicate_action {
1 => true,
2 => {
diff --git a/crates/app/src/model.rs b/crates/app/src/model.rs
index 484e0369..20e36d51 100644
--- a/crates/app/src/model.rs
+++ b/crates/app/src/model.rs
@@ -1113,3 +1113,32 @@ mod address_tests {
assert!(super::parse_address("not an address").is_err());
}
}
+
+/// A finished download whose file was moved or deleted (#342). Not when its folder is gone too:
+/// that is more likely a drive that is unplugged, and the file may come back.
+pub fn finished_file_gone(status: Status, dest: &std::path::Path) -> bool {
+ status == Status::Complete && !dest.exists() && dest.parent().is_some_and(|d| d.is_dir())
+}
+
+#[cfg(test)]
+mod finished_file_gone_tests {
+ use super::*;
+
+ #[test]
+ fn only_a_finished_file_gone_from_a_folder_that_is_there() {
+ let dir = std::env::temp_dir().join(format!("mdm-342-{}", std::process::id()));
+ std::fs::create_dir_all(&dir).unwrap();
+ let there = dir.join("there.bin");
+ std::fs::write(&there, b"x").unwrap();
+ assert!(!finished_file_gone(Status::Complete, &there));
+ assert!(finished_file_gone(Status::Complete, &dir.join("gone.bin")));
+ // Not finished: its file isn't expected yet.
+ assert!(!finished_file_gone(Status::Queued, &dir.join("gone.bin")));
+ // Its folder is gone too: maybe a drive that is unplugged.
+ assert!(!finished_file_gone(
+ Status::Complete,
+ &dir.join("no").join("gone.bin")
+ ));
+ std::fs::remove_dir_all(&dir).unwrap();
+ }
+}