aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-12-20 14:30:39 +0000
committerBibiko <bibiko@eva.mpg.de>2010-12-20 14:30:39 +0000
commitd23a09dbbc88a0e10d36b05bbacbca8c1dec3147 (patch)
treef179c05460753d3960202de0473e14337e13841e /Source
parentd442e29e22e7cdb8a36f2bf3d2ad7cfc8910a0e9 (diff)
downloadsequelpro-d23a09dbbc88a0e10d36b05bbacbca8c1dec3147.tar.gz
sequelpro-d23a09dbbc88a0e10d36b05bbacbca8c1dec3147.tar.bz2
sequelpro-d23a09dbbc88a0e10d36b05bbacbca8c1dec3147.zip
• further preparations for default Bundles management
Diffstat (limited to 'Source')
-rw-r--r--Source/SPAppController.m61
-rw-r--r--Source/SPBundleEditorController.m2
2 files changed, 51 insertions, 12 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index ec315f78..63be06c0 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -528,11 +528,11 @@
} else {
// Check for installed UUIDs
if(![cmdData objectForKey:SPBundleFileUUIDKey]) {
- NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while installing bundle file", @"error while installing bundle file")]
+ NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while installing Bundle", @"error while installing bundle")]
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
otherButton:nil
- informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"The bundle ‘%@’ has no UUID which is necessary to identify installed bundles.", @"the bundle ‘%@’ has no UUID which is necessary to identify installed bundles."), [filename lastPathComponent]]];
+ informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"The Bundle ‘%@’ has no UUID which is necessary to identify installed Bundles.", @"the bundle ‘%@’ has no UUID which is necessary to identify installed bundles."), [filename lastPathComponent]]];
[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];
@@ -540,11 +540,11 @@
return;
}
if([[installedBundleUUIDs allKeys] containsObject:[cmdData objectForKey:SPBundleFileUUIDKey]]) {
- NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Installing bundle file", @"installing bundle file")]
+ NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Installing Bundle", @"installing bundle")]
defaultButton:NSLocalizedString(@"Update", @"Update button")
alternateButton:NSLocalizedString(@"Cancel", @"Cancel button")
otherButton:nil
- informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"A bundle ‘%@’ is already installed. Do you want to update it?", @"a bundle ‘%@’ is already installed. do you want to update it?"), [[installedBundleUUIDs objectForKey:[cmdData objectForKey:SPBundleFileUUIDKey]] objectForKey:@"name"]]];
+ informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"A Bundle ‘%@’ is already installed. Do you want to update it?", @"a bundle ‘%@’ is already installed. do you want to update it?"), [[installedBundleUUIDs objectForKey:[cmdData objectForKey:SPBundleFileUUIDKey]] objectForKey:@"name"]]];
[alert setAlertStyle:NSCriticalAlertStyle];
NSInteger answer = [alert runModal];
@@ -590,11 +590,11 @@
[self reloadBundles:self];
} else {
- NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while installing bundle file", @"error while installing bundle file")]
+ NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while installing Bundle", @"error while installing bundle")]
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
otherButton:nil
- informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"The bundle ‘%@’ already exists.", @"the bundle ‘%@’ already exists."), [filename lastPathComponent]]];
+ informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"The Bundle ‘%@’ already exists.", @"the bundle ‘%@’ already exists."), [filename lastPathComponent]]];
[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];
@@ -1380,7 +1380,7 @@
continue;
// If default Bundle is already install check for possible update,
- // if so duplicate the 'old one' by renaming it and change the UUID
+ // if so ask the user for updating or skipping; if update move old bundle to Trash
if([installedBundleUUIDs objectForKey:[cmdData objectForKey:SPBundleFileUUIDKey]]) {
if([updatedDefaultBundles containsObject:[cmdData objectForKey:SPBundleFileUUIDKey]]) {
NSString *oldPath = [NSString stringWithFormat:@"%@/%@/%@", [bundlePaths objectAtIndex:0], bundle, SPBundleFileName];
@@ -1394,27 +1394,64 @@
if(!cmdData || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) {
NSLog(@"“%@” file couldn't be read.", oldPath);
NSBeep();
+ if (cmdData) [cmdData release];
continue;
} else {
// Check for modifications
if([cmdData objectForKey:SPBundleFileDefaultBundleWasModifiedKey]) {
-
+ NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Updating default Bundle", @"updating default bundle")]
+ defaultButton:NSLocalizedString(@"Update", @"Update button")
+ alternateButton:NSLocalizedString(@"Skip", @"Skip button")
+ otherButton:nil
+ informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"There is an update for ‘%@’ available. Do you want to update it and loose your modifications? If you choose ‘Skip’ in order to incorporate your modifications please duplicate this Bundle and restart Sequel Pro to update it. Otherwise Sequel Pro will ask you again.", @"there is an update for ‘%@’ available. do you want to update it and loose your modifications? if you choose ‘skip’ in order to incorporate your modifications please duplicate this bundle and restart sequel pro to update it. otherwise sequel pro will ask you again."), [[installedBundleUUIDs objectForKey:[cmdData objectForKey:SPBundleFileUUIDKey]] objectForKey:@"name"]]];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ NSInteger answer = [alert runModal];
+ if(answer == NSAlertDefaultReturn) {
+ NSError *error = nil;
+ NSString *moveToTrashCommand = [NSString stringWithFormat:@"osascript -e 'tell application \"Finder\" to move (POSIX file \"%@\") to the trash'", [NSString stringWithFormat:@"%@/%@", [bundlePaths objectAtIndex:0], bundle]];
+ [moveToTrashCommand runBashCommandWithEnvironment:nil atCurrentDirectoryPath:nil error:&error];
+ if(error != nil) {
+ NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while moving “%@” to Trash.", @"error while moving “%@” to trash"), [[installedBundleUUIDs objectForKey:[cmdData objectForKey:SPBundleFileUUIDKey]] objectForKey:@"path"]]
+ defaultButton:NSLocalizedString(@"OK", @"OK button")
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:[error localizedDescription]];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+ [alert runModal];
+ if (cmdData) [cmdData release];
+ }
+ [updatedDefaultBundles removeObject:[cmdData objectForKey:SPBundleFileUUIDKey]];
+ } else {
+ if (cmdData) [cmdData release];
+ continue;
+ }
} else {
- [fm removeItemAtPath:[NSString stringWithFormat:@"%@/%@", [bundlePaths objectAtIndex:0], bundle]];
+ if(![fm removeItemAtPath:[NSString stringWithFormat:@"%@/%@", [bundlePaths objectAtIndex:0], bundle] error:nil]) {
+ NSLog(@"Couldn't remove “%@” to update it", bundle);
+ NSBeep();
+ }
[updatedDefaultBundles removeObject:[cmdData objectForKey:SPBundleFileUUIDKey]];
}
}
+ if (cmdData) [cmdData release];
+
} else {
+
continue;
+
}
}
BOOL isDir;
NSString *newInfoPath = [NSString stringWithFormat:@"%@/%@/%@", [bundlePaths objectAtIndex:0], bundle, SPBundleFileName];
- if([fm fileExistsAtPath:newInfoPath isDirectory:&isDir] && isDir)
- newInfoPath = [NSString stringWithFormat:@"%@_%ld", newInfoPath, (NSUInteger)(random() % 35000)];
+ NSString *orgPath = [NSString stringWithFormat:@"%@/%@", [bundlePaths objectAtIndex:1], bundle];
+ NSString *newPath = [NSString stringWithFormat:@"%@/%@", [bundlePaths objectAtIndex:0], bundle];
+ if([fm fileExistsAtPath:newPath isDirectory:&isDir] && isDir)
+ newPath = [NSString stringWithFormat:@"%@_%ld", newPath, (NSUInteger)(random() % 35000)];
NSError *error = nil;
- [fm moveItemAtPath:infoPath toPath:newInfoPath error:&error];
+ [fm copyItemAtPath:orgPath toPath:newPath error:&error];
if(error != nil) {
NSBeep();
NSLog(@"Default Bundle “%@” couldn't be moved to '%@'", bundle, newInfoPath);
diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m
index 82c93047..cf6478fe 100644
--- a/Source/SPBundleEditorController.m
+++ b/Source/SPBundleEditorController.m
@@ -922,6 +922,7 @@
if(!cmdData || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) {
NSLog(@"“%@” file couldn't be read.", cmdFilePath);
NSBeep();
+ if (cmdData) [cmdData release];
return NO;
} else {
// Check for changes and return if no changes are found
@@ -930,6 +931,7 @@
if([cmdData objectForKey:SPBundleFileIsDefaultBundleKey])
[saveDict setObject:[NSNumber numberWithBool:YES] forKey:SPBundleFileDefaultBundleWasModifiedKey];
}
+ if (cmdData) [cmdData release];
}
// Remove a given old command.plist file