mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-15 11:13:29 +00:00
Fix bug 323847: save a copy of the corrupted bookmarks file when we fail to read bookmarks.
This commit is contained in:
parent
d0645e169e
commit
0848e5b26a
@ -1112,7 +1112,6 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
||||
// them or we may get this event at startup before we've had time to load
|
||||
// our window.
|
||||
BrowserWindowController* controller = (BrowserWindowController*)[[self getFrontmostBrowserWindow] windowController];
|
||||
BOOL tabOrWindowIsAvailable = (controller && [[controller getBrowserWrapper] isEmpty] && ![[controller getBrowserWrapper] isBusy]);
|
||||
if (controller) {
|
||||
BOOL tabOrWindowIsAvailable = ([[controller getBrowserWrapper] isEmpty] && ![[controller getBrowserWrapper] isBusy]);
|
||||
|
||||
|
@ -1175,6 +1175,13 @@ static BookmarkManager* gBookmarkManager = nil;
|
||||
{
|
||||
if ([self readPListBookmarks:bookmarkPath])
|
||||
return YES;
|
||||
else
|
||||
{
|
||||
// save the corrupted bookmarks to a backup file
|
||||
NSString* uniqueName = [fM backupFileNameFromPath:bookmarkPath withSuffix:@"-corrupted"];
|
||||
[fM copyPath:bookmarkPath toPath:uniqueName handler:nil];
|
||||
NSLog(@"Copied corrupted bookmarks file to %@", uniqueName);
|
||||
}
|
||||
}
|
||||
else if ([fM isReadableFileAtPath:[profileDir stringByAppendingPathComponent:@"bookmarks.xml"]])
|
||||
{
|
||||
|
@ -45,4 +45,8 @@
|
||||
// this will return -1 on error
|
||||
- (long long)sizeOfFileAtPath:(NSString*)inPath traverseLink:(BOOL)inTraverseLink;
|
||||
|
||||
// make a name for a backup file with the given path and suffix
|
||||
// (e.g. bookmarks.plist will be changed to "bookmarksSUFFIX-1.plist".
|
||||
- (NSString*)backupFileNameFromPath:(NSString*)inPath withSuffix:(NSString*)inFileSuffix;
|
||||
|
||||
@end
|
||||
|
@ -81,5 +81,25 @@
|
||||
return [fileSize longLongValue];
|
||||
}
|
||||
|
||||
- (NSString*)backupFileNameFromPath:(NSString*)inPath withSuffix:(NSString*)inFileSuffix
|
||||
{
|
||||
NSString* pathWithoutExtension = [inPath stringByDeletingPathExtension];
|
||||
NSString* fileExtension = [inPath pathExtension];
|
||||
|
||||
int sequenceNumber = 1;
|
||||
|
||||
NSString* newName = nil;
|
||||
|
||||
do {
|
||||
NSString* sequenceString = [NSString stringWithFormat:@"%@-%d", inFileSuffix, sequenceNumber];
|
||||
|
||||
newName = [pathWithoutExtension stringByAppendingString:sequenceString];
|
||||
newName = [newName stringByAppendingPathExtension:fileExtension];
|
||||
|
||||
++sequenceNumber;
|
||||
} while ([self fileExistsAtPath:newName]);
|
||||
|
||||
return newName;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user