From b31346eec6dfddaf8aa27f71e06488bbcdaac333 Mon Sep 17 00:00:00 2001 From: "smfr%smfr.org" Date: Mon, 14 Nov 2005 04:31:58 +0000 Subject: [PATCH] Add a check for a file size > 0 when saving bookmarks, and add some logging to try to catch the losing bookmarks problem. --- camino/src/bookmarks/BookmarkManager.mm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/camino/src/bookmarks/BookmarkManager.mm b/camino/src/bookmarks/BookmarkManager.mm index df984160519..9d11e3791cb 100644 --- a/camino/src/bookmarks/BookmarkManager.mm +++ b/camino/src/bookmarks/BookmarkManager.mm @@ -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);