aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-11-11 15:09:14 +0000
committerstuconnolly <stuart02@gmail.com>2010-11-11 15:09:14 +0000
commitb8fc79dd357d8dd1cf3177d1a7faef030497a9e0 (patch)
tree555c6854dfcd7bda2a6121a32a08bc5398b4a88b
parent98f00f7707b780c33d0918350c9f8a353e6d8d79 (diff)
downloadsequelpro-b8fc79dd357d8dd1cf3177d1a7faef030497a9e0.tar.gz
sequelpro-b8fc79dd357d8dd1cf3177d1a7faef030497a9e0.tar.bz2
sequelpro-b8fc79dd357d8dd1cf3177d1a7faef030497a9e0.zip
Commenting and move SPFavoriteNode within Xcode's logical structure.
-rw-r--r--Source/SPFavoritesController.m5
-rw-r--r--sequel-pro.xcodeproj/project.pbxproj4
2 files changed, 7 insertions, 2 deletions
diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m
index 85f4e587..08df59c8 100644
--- a/Source/SPFavoritesController.m
+++ b/Source/SPFavoritesController.m
@@ -98,6 +98,7 @@ static SPFavoritesController *sharedFavoritesController = nil;
NSString *favoritesFile = [dataPath stringByAppendingPathComponent:SPFavoritesDataFile];
NSString *favoritesBackupFile = [dataPath stringByAppendingPathComponent:[@"~" stringByAppendingString:SPFavoritesDataFile]];
+ // If the favorites data file already exists, attempt to move it to keep as a backup
if ([fileManager fileExistsAtPath:favoritesFile]) {
[fileManager moveItemAtPath:favoritesFile toPath:favoritesBackupFile error:&error];
}
@@ -107,6 +108,7 @@ static SPFavoritesController *sharedFavoritesController = nil;
error = nil;
+ // We can't move it so try and delete it
if (![fileManager removeItemAtPath:favoritesFile error:&error] && error) {
NSLog(@"Unable to delete existing favorites data file during save. Something is wrong, permissions perhaps: %@", [error localizedDescription]);
return;
@@ -123,9 +125,11 @@ static SPFavoritesController *sharedFavoritesController = nil;
if (error) {
NSLog(@"Error writing favorites data. Restoring backup if available: %@", [error localizedDescription]);
+ // Restore the original data file
[fileManager moveItemAtPath:favoritesBackupFile toPath:favoritesFile error:NULL];
}
else {
+ // Remove the original backup
[fileManager removeItemAtPath:favoritesBackupFile error:NULL];
}
}
@@ -173,6 +177,7 @@ static SPFavoritesController *sharedFavoritesController = nil;
NSString *favoritesFile = [dataPath stringByAppendingPathComponent:SPFavoritesDataFile];
+ // If the favorites data file already exists use it, otherwise create an empty one
if ([fileManager fileExistsAtPath:favoritesFile]) {
favorites = [[NSDictionary alloc] initWithContentsOfFile:favoritesFile];
}
diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj
index 304072c1..318852f6 100644
--- a/sequel-pro.xcodeproj/project.pbxproj
+++ b/sequel-pro.xcodeproj/project.pbxproj
@@ -1677,8 +1677,6 @@
17D38FC2127B0C9500672B13 /* Connection View */ = {
isa = PBXGroup;
children = (
- 17D3C22012859E070047709F /* SPFavoriteNode.h */,
- 17D3C22112859E070047709F /* SPFavoriteNode.m */,
5822C9B31000DB2400DCC3D6 /* SPConnectionController.h */,
5822C9B41000DB2400DCC3D6 /* SPConnectionController.m */,
17D3C6021289BF350047709F /* SPConnectionControllerDelegate.h */,
@@ -1921,6 +1919,8 @@
BCA6271B1031B9D40047E5D5 /* SPTooltip.m */,
17D3C66F128AD8160047709F /* SPSingleton.h */,
17D3C670128AD8160047709F /* SPSingleton.m */,
+ 17D3C22012859E070047709F /* SPFavoriteNode.h */,
+ 17D3C22112859E070047709F /* SPFavoriteNode.m */,
172A650F0F7BED7A001E861A /* SPConsoleMessage.h */,
172A65100F7BED7A001E861A /* SPConsoleMessage.m */,
17C058860FC9FC390077E9CF /* SPNarrowDownCompletion.h */,