aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFavoritesController.m
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 /Source/SPFavoritesController.m
parent98f00f7707b780c33d0918350c9f8a353e6d8d79 (diff)
downloadsequelpro-b8fc79dd357d8dd1cf3177d1a7faef030497a9e0.tar.gz
sequelpro-b8fc79dd357d8dd1cf3177d1a7faef030497a9e0.tar.bz2
sequelpro-b8fc79dd357d8dd1cf3177d1a7faef030497a9e0.zip
Commenting and move SPFavoriteNode within Xcode's logical structure.
Diffstat (limited to 'Source/SPFavoritesController.m')
-rw-r--r--Source/SPFavoritesController.m5
1 files changed, 5 insertions, 0 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];
}