Permalink
Browse files

correctly detect an error when trying to delete a plug-in that doesn'…

…t exist

the `removeItemAtPath:` method returns YES when the path is nil, masking the failure
  • Loading branch information...
1 parent aa03540 commit 1b22bcb260d1798358fbd6547971b9b5bfdc025b @skurfer committed Feb 20, 2012
Showing with 12 additions and 6 deletions.
  1. +11 −5 Quicksilver/Code-QuickStepCore/QSPlugIn.m
  2. +1 −1 Quicksilver/Code-QuickStepCore/QSPlugInManager.m
@@ -473,18 +473,24 @@ - (BOOL)reveal {
inFileViewerRootedAtPath:@""];
}
- (BOOL)delete {
- NSString *ident/*, *path*/;
- if(bundle) {
+ NSString *ident, *path;
+ if (bundle) {
ident = [bundle bundleIdentifier];
-// path = [bundle bundlePath];
+ path = [bundle bundlePath];
} else {
ident = [data objectForKey:@"CFBundleIdentifier"];
-// path = nil;
+ path = nil;
}
id manager = [QSPlugInManager sharedInstance];
[[manager localPlugIns] removeObjectForKey:ident];
[[manager knownPlugIns] removeObjectForKey:ident];
- return [[NSFileManager defaultManager] removeItemAtPath:[bundle bundlePath] error:nil];
+ NSFileManager *fm = [NSFileManager defaultManager];
+ if ([fm fileExistsAtPath:path]) {
+ return [fm removeItemAtPath:path error:nil];
+ } else {
+ return NO;
+ }
+ return YES;
}
//------------------------
@@ -322,7 +322,7 @@ - (void)deletePlugIns:(NSArray *)deletePlugIns fromWindow:(NSWindow *)window {
result = NSRunCriticalAlertPanel(@"Delete plug-ins?", @"Would you like to delete the selected plug-ins?", @"Delete", @"Cancel", nil);
if (result) {
- BOOL success = 1;
+ BOOL success = YES;
for(QSPlugIn * plugin in deletePlugIns) {
success = success && [plugin delete];
}

0 comments on commit 1b22bcb

Please sign in to comment.