mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 22:52:26 +00:00
Plugins cannot be loaded more than once
This commit is contained in:
@@ -111,6 +111,11 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu
|
||||
continue;
|
||||
};
|
||||
|
||||
if([self _validateBundle:pluginBundle]) {
|
||||
NSLog(@"Plugin %@ already loaded!", pluginBundle.bundleIdentifier);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(![pluginBundle loadAndReturnError:&error]) {
|
||||
NSLog(@"Bunlde Loading Error %@ %@", error.localizedDescription, error.localizedFailureReason);
|
||||
continue;
|
||||
@@ -137,6 +142,16 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)_validateBundle:(NSBundle *)bundle {
|
||||
for(MPPlugin *plugin in self.mutablePlugins) {
|
||||
NSBundle *pluginBundle = [NSBundle bundleForClass:plugin.class];
|
||||
if([pluginBundle.bundleIdentifier isEqualToString:bundle.bundleIdentifier]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)_validURL:(NSURL *)url {
|
||||
return (NSOrderedSame == [url.pathExtension compare:kMPPluginFileExtension options:NSCaseInsensitiveSearch]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user