From 22225d69af480bccc2d1038b1b9469402e35234b Mon Sep 17 00:00:00 2001 From: Huge_Black Date: Sun, 30 Mar 2025 18:56:53 +0800 Subject: [PATCH] fix race condition --- StikJIT/Utilities/AppStoreIconFetcher.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/StikJIT/Utilities/AppStoreIconFetcher.swift b/StikJIT/Utilities/AppStoreIconFetcher.swift index 3d01810..c093386 100644 --- a/StikJIT/Utilities/AppStoreIconFetcher.swift +++ b/StikJIT/Utilities/AppStoreIconFetcher.swift @@ -10,6 +10,7 @@ import UIKit // Not AppStore class AppStoreIconFetcher { static private var iconCache: [String: UIImage] = [:] + static private let iconFetchDispatchQueue = DispatchQueue(label: "com.stik.StikJIT.iconFetchQueue", attributes: .concurrent) static func getIcon(for bundleID: String, completion: @escaping (UIImage?) -> Void) { // Check cache first @@ -18,7 +19,7 @@ class AppStoreIconFetcher { return } - Task { + iconFetchDispatchQueue.sync { do { let ans = try JITEnableContext.shared.getAppIcon(withBundleId: bundleID) iconCache[bundleID] = ans