Skip to content

Commit 6dd9170

Browse files
committed
[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.
1 parent d351d5d commit 6dd9170

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

AltServer/Plugin/PluginManager.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ class PluginManager
6666
do
6767
{
6868
// If Mail plug-in is not yet installed, then there is no update available.
69-
guard let bundle = Bundle(url: pluginURL) else { return completionHandler(.success(false)) }
69+
var isDirectory: ObjCBool = false
70+
guard FileManager.default.fileExists(atPath: pluginURL.path, isDirectory: &isDirectory), isDirectory.boolValue else { return completionHandler(.success(false)) }
7071

7172
// Load Info.plist from disk because Bundle.infoDictionary is cached by system.
72-
let infoDictionaryURL = bundle.bundleURL.appendingPathComponent("Contents/Info.plist")
73+
let infoDictionaryURL = pluginURL.appendingPathComponent("Contents/Info.plist")
7374
guard let infoDictionary = NSDictionary(contentsOf: infoDictionaryURL) as? [String: Any],
7475
let localVersion = infoDictionary["CFBundleShortVersionString"] as? String
7576
else { throw CocoaError(.fileReadCorruptFile, userInfo: [NSURLErrorKey: infoDictionaryURL]) }

0 commit comments

Comments
 (0)