From 5f6440c7b2e2dc487495e3027a634eff9b18a892 Mon Sep 17 00:00:00 2001 From: Avighna Date: Sat, 8 Aug 2026 22:46:30 +0530 Subject: [PATCH] Fix bug where `listRefresh()` would not deduplicate VMs --- Platform/UTMData.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Platform/UTMData.swift b/Platform/UTMData.swift index 2af61c5ae1..32820875d2 100644 --- a/Platform/UTMData.swift +++ b/Platform/UTMData.swift @@ -144,12 +144,18 @@ enum AlertItem: Identifiable { /// /// This removes stale entries (deleted/not accessible) and duplicate entries func listRefresh() async { + // deduplicate VM list + var list: [VMData] = []; + for vm in virtualMachines { + if !list.contains(where: { isSameFile($0.pathUrl, as: vm.pathUrl) }) { + list.append(vm) + } + } // create Documents directory if it doesn't exist if !fileManager.fileExists(atPath: Self.defaultStorageUrl.path) { try? fileManager.createDirectory(at: Self.defaultStorageUrl, withIntermediateDirectories: false) } // wrap stale VMs - var list = virtualMachines for i in list.indices.reversed() { let vm = list[i] if let registryEntry = vm.registryEntry, !fileManager.fileExists(atPath: registryEntry.package.path) {