зеркало из https://github.com/mozilla/pjs.git
Add a check for a file size > 0 when saving bookmarks, and add some logging to try to catch the losing bookmarks problem.
This commit is contained in:
Родитель
b9c7a5e0f0
Коммит
b31346eec6
|
@ -1712,20 +1712,19 @@ static BookmarkManager* gBookmarkManager = nil;
|
|||
BOOL success = [dict writeToFile:backupFile atomically:YES];
|
||||
if (success)
|
||||
{
|
||||
// XXX removed to measure hit on startup perf
|
||||
// long long bmFileSize = [[NSFileManager defaultManager] sizeOfFileAtPath:backupFile traverseLink:YES];
|
||||
// if (bmFileSize > 0)
|
||||
NSFileManager* fm = [NSFileManager defaultManager];
|
||||
long long bmFileSize = [fm sizeOfFileAtPath:backupFile traverseLink:YES];
|
||||
if (bmFileSize > 0)
|
||||
{
|
||||
NSFileManager* fm = [NSFileManager defaultManager];
|
||||
BOOL removedOld = [fm removeFileAtPath:stdPath handler:self]; // out with the old...
|
||||
BOOL movedNew = [fm movePath:backupFile toPath:stdPath handler:self]; // ... in with the new
|
||||
if (!removedOld || !movedNew)
|
||||
NSLog(@"writePropertyList: move failed (removed old file at %@ %d, moved new file from %@ %d",
|
||||
NSLog(@"writePropertyList: move failed (removed old file at %@ (OK %d), moved new file from %@ (OK %d)",
|
||||
stdPath, removedOld,
|
||||
backupFile, movedNew);
|
||||
}
|
||||
// else
|
||||
// NSLog(@"writePropertyList: saved bookmarks file was empty (%qi bytes))", bmFileSize);
|
||||
else
|
||||
NSLog(@"writePropertyList: saved bookmarks file was empty (%qi bytes))", bmFileSize);
|
||||
}
|
||||
else
|
||||
NSLog(@"writePropertyList: Failed to write file %@", pathToFile);
|
||||
|
|
Загрузка…
Ссылка в новой задаче