From d82bb80e144131e572ea03028f262b4bfd6b2167 Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Sun, 13 Aug 2023 15:02:45 -0700 Subject: [PATCH] Fix #478 (#479) --- .../Sources/SecretAgentKit/SigningRequestTracer.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Packages/Sources/SecretAgentKit/SigningRequestTracer.swift b/Sources/Packages/Sources/SecretAgentKit/SigningRequestTracer.swift index 7e87538..aa8e295 100644 --- a/Sources/Packages/Sources/SecretAgentKit/SigningRequestTracer.swift +++ b/Sources/Packages/Sources/SecretAgentKit/SigningRequestTracer.swift @@ -60,7 +60,10 @@ extension SigningRequestTracer { func iconURL(for pid: Int32) -> URL? { do { if let app = NSRunningApplication(processIdentifier: pid), let icon = app.icon?.tiffRepresentation { - let temporaryURL = URL(fileURLWithPath: (NSTemporaryDirectory() as NSString).appendingPathComponent("\(UUID().uuidString).png")) + let temporaryURL = URL(fileURLWithPath: (NSTemporaryDirectory() as NSString).appendingPathComponent("\(app.bundleIdentifier ?? UUID().uuidString).png")) + if FileManager.default.fileExists(atPath: temporaryURL.path) { + return temporaryURL + } let bitmap = NSBitmapImageRep(data: icon) try bitmap?.representation(using: .png, properties: [:])?.write(to: temporaryURL) return temporaryURL