[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

sullivan sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:37:45 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 2c3d64623df55db6a4bd1e423840d85d4d5815be
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Apr 18 00:43:58 2003 +0000

    	- fixed 3232332 -- History file should be versioned since
    	we might change it in the future
    	- fixed 3220355 -- Console error message at launch when
    	there's no history file
    
    	Note: a downside of this change is that the history formats
    	before and after this change are not compatible. You will
    	get no history each time you cross that boundary by running
    	different Safaris.
    
            Reviewed by Maciej.
    
            * History.subproj/WebHistoryPrivate.m:
            (-[WebHistoryPrivate _loadHistoryGuts:]):
    	check for file-doesn't-exist case before complaining about
    	being unable to read existing file; expect to read dictionary
    	rather than array, and check version in dictionary.
            (-[WebHistoryPrivate _saveHistoryGuts:]):
    	save dictionary that includes version as well as array of
    	items by date.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4137 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 25aa815..95bd6a7 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,26 @@
+2003-04-17  John Sullivan  <sullivan at apple.com>
+
+	- fixed 3232332 -- History file should be versioned since 
+	we might change it in the future
+	- fixed 3220355 -- Console error message at launch when 
+	there's no history file
+
+	Note: a downside of this change is that the history formats
+	before and after this change are not compatible. You will
+	get no history each time you cross that boundary by running
+	different Safaris.
+
+        Reviewed by Maciej.
+
+        * History.subproj/WebHistoryPrivate.m:
+        (-[WebHistoryPrivate _loadHistoryGuts:]):
+	check for file-doesn't-exist case before complaining about
+	being unable to read existing file; expect to read dictionary
+	rather than array, and check version in dictionary.
+        (-[WebHistoryPrivate _saveHistoryGuts:]):
+	save dictionary that includes version as well as array of
+	items by date.
+
 2003-04-17  Richard Williamson   <rjw at apple.com>
 
         Fixed typos in headerdoc comments.
diff --git a/WebKit/History.subproj/WebHistoryPrivate.m b/WebKit/History.subproj/WebHistoryPrivate.m
index 7980b27..b2eac69 100644
--- a/WebKit/History.subproj/WebHistoryPrivate.m
+++ b/WebKit/History.subproj/WebHistoryPrivate.m
@@ -15,6 +15,10 @@
 #import <WebFoundation/WebNSCalendarDateExtras.h>
 #import <WebFoundation/WebNSURLExtras.h>
 
+NSString *FileVersionKey = @"WebHistoryFileVersion";
+NSString *DatesArrayKey = @"WebHistoryDates";
+
+#define currentFileVersion	1
 
 @implementation WebHistoryPrivate
 
@@ -344,9 +348,7 @@
 
 - (BOOL)_loadHistoryGuts: (int *)numberOfItemsLoaded
 {
-    NSArray *array;
     NSEnumerator *enumerator;
-    NSDictionary *dictionary;
     int index;
     int limit;
     NSCalendarDate *ageLimitDate;
@@ -354,12 +356,32 @@
 
     *numberOfItemsLoaded = 0;
 
-    array = [NSArray arrayWithContentsOfURL: [self URL]];
-    if (array == nil) {
-        ERROR("attempt to read history from %@ failed; perhaps contents are corrupted", [[self URL] absoluteString]);
+    NSDictionary *fileAsDictionary = [NSDictionary dictionaryWithContentsOfURL: [self URL]];
+    if (fileAsDictionary == nil) {
+#if !ERROR_DISABLED
+        if ([[self URL] isFileURL] && [[NSFileManager defaultManager] fileExistsAtPath: [[self URL] path]]) {
+            ERROR("unable to read history from file %@; perhaps contents are corrupted", [[self URL] path]);
+        }
+#endif
         return NO;
     }
 
+    NSNumber *fileVersionObject = [fileAsDictionary objectForKey:FileVersionKey];
+    int fileVersion;
+    // we don't trust data read from disk, so double-check
+    if (fileVersionObject != nil && [fileVersionObject isKindOfClass:[NSNumber class]]) {
+        fileVersion = [fileVersionObject intValue];
+    } else {
+        ERROR("history file version can't be determined, therefore not loading");
+        return NO;
+    }
+    if (fileVersion > currentFileVersion) {
+        ERROR("history file version is %d, newer than newest known version %d, therefore not loading", fileVersion, currentFileVersion);
+        return NO;
+    }    
+
+    NSArray *array = [fileAsDictionary objectForKey:DatesArrayKey];
+        
     limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
     ageLimitDate = [self _ageLimitDate];
     index = 0;
@@ -367,10 +389,11 @@
     enumerator = [array reverseObjectEnumerator];
     ageLimitPassed = NO;
 
-    while ((dictionary = [enumerator nextObject]) != nil) {
+    NSDictionary *itemAsDictionary;
+    while ((itemAsDictionary = [enumerator nextObject]) != nil) {
         WebHistoryItem *entry;
 
-        entry = [[[WebHistoryItem alloc] initFromDictionaryRepresentation: dictionary] autorelease];
+        entry = [[[WebHistoryItem alloc] initFromDictionaryRepresentation:itemAsDictionary] autorelease];
 
         if ([entry URL] == nil || [entry lastVisitedDate] == nil) {
             // entry without URL is useless; data on disk must have been bad; ignore this one
@@ -417,12 +440,15 @@
 
 - (BOOL)_saveHistoryGuts: (int *)numberOfItemsSaved
 {
-    NSArray *array;
     *numberOfItemsSaved = 0;
 
-    array = [self arrayRepresentation];
-    if (![array writeToURL:[self URL] atomically:YES]) {
-        ERROR("attempt to save %@ to %@ failed", array, [[self URL] absoluteString]);
+    NSArray *array = [self arrayRepresentation];
+    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+        array, DatesArrayKey,
+        [NSNumber numberWithInt:currentFileVersion], FileVersionKey,
+        nil];
+    if (![dictionary writeToURL:[self URL] atomically:YES]) {
+        ERROR("attempt to save %@ to %@ failed", dictionary, [[self URL] absoluteString]);
         return NO;
     }
     

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list