From a8115d748e84f4568c10184ce41a04b60df78c41 Mon Sep 17 00:00:00 2001 From: Oscar Busk Date: Fri, 20 Feb 2026 14:59:40 +0100 Subject: [PATCH] Fix file showing as both winning and losing in 3+ archive conflicts When three or more archives contain the same file, the middle archive could end up with that file in both its `wins` and `loses` lists. This happened because the reverse-iteration conflict scan would first mark the middle archive as winning (when compared to the earlier archive), then a later iteration would mark it as losing (when superseded by the last archive) without clearing the stale `wins` entry. Now when an archive is marked as losing a file, any previous winning entry for that file is removed, so each file hash only appears in one of the two lists. Co-Authored-By: Claude (cherry picked from commit 3b66befdd95407681cb5e139c4858077c9a9801e) --- red4-conflicts/src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/red4-conflicts/src/lib.rs b/red4-conflicts/src/lib.rs index fe44de2..1287888 100644 --- a/red4-conflicts/src/lib.rs +++ b/red4-conflicts/src/lib.rs @@ -151,8 +151,13 @@ impl TemplateApp { // update vms // add this file to all previous archive's losing files for archive in archive_names.iter() { - if !self.archives.get(archive).unwrap().loses.contains(hash) { - self.archives.get_mut(archive).unwrap().loses.push(*hash); + let archive_vm = self.archives.get_mut(archive).unwrap(); + if !archive_vm.loses.contains(hash) { + archive_vm.loses.push(*hash); + } + // remove from wins if previously marked as winning + if let Some(pos) = archive_vm.wins.iter().position(|w| w == hash) { + archive_vm.wins.remove(pos); } } // add the current archive to the list of conflicting archives last