From cf6448845fcf02db76bc4935ad2654db2ee8b034 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Wed, 25 May 2022 15:17:58 -0700 Subject: [PATCH] [AltServer] Fixes installing AltPlugin after uninstalling it Bundle(url:) is cached, so even if AltPlugin is deleted Bundle(url:) will still return a non-nil value. Instead, we now directly check whether a directory exists at pluginURL to determine if AltPlugin is installed. --- AltServer/Plugin/PluginManager.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AltServer/Plugin/PluginManager.swift b/AltServer/Plugin/PluginManager.swift index bb0d99e4..fb2e9c09 100644 --- a/AltServer/Plugin/PluginManager.swift +++ b/AltServer/Plugin/PluginManager.swift @@ -66,10 +66,11 @@ class PluginManager do { // If Mail plug-in is not yet installed, then there is no update available. - guard let bundle = Bundle(url: pluginURL) else { return completionHandler(.success(false)) } + var isDirectory: ObjCBool = false + guard FileManager.default.fileExists(atPath: pluginURL.path, isDirectory: &isDirectory), isDirectory.boolValue else { return completionHandler(.success(false)) } // Load Info.plist from disk because Bundle.infoDictionary is cached by system. - let infoDictionaryURL = bundle.bundleURL.appendingPathComponent("Contents/Info.plist") + let infoDictionaryURL = pluginURL.appendingPathComponent("Contents/Info.plist") guard let infoDictionary = NSDictionary(contentsOf: infoDictionaryURL) as? [String: Any], let localVersion = infoDictionary["CFBundleShortVersionString"] as? String else { throw CocoaError(.fileReadCorruptFile, userInfo: [NSURLErrorKey: infoDictionaryURL]) }