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

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:17:38 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 7b43d55fac9db5d2a9aa375defd5e33066496734
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jun 7 22:58:00 2002 +0000

    2002-06-07  Kenneth Kocienda  <kocienda at apple.com>
    
            Reviewed by: Darin Adler
    
            Fix for this bug:
    
            Radar 2936755 (.size can get out of synch with actual cache size on disk)
    
            Four separate fixes to make sure the .size file stays in sync with the
            cumulative size of the cache files on disk.
    
            These fixes are:
    
            1) Check that usage decrease when a file is removed is only done when removal succeeds.
            2) Account for a cache file that gets rewritten to disk with a different size
               than the file it is replacing.
            3) Remove pending disk operations when the user clears the cache.
            4) Make sure usage gets set back to zero on a cache clear.
    
            * Database.subproj/IFURLFileDatabase.m:
            (-[IFURLFileDatabase writeSizeFile:])
            (-[IFURLFileDatabase removeAllObjects])
            (-[IFURLFileDatabase performSetObject:forKey:])
            (-[IFURLFileDatabase performRemoveObjectForKey:])
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1301 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/Misc.subproj/WebFileDatabase.m b/WebKit/Misc.subproj/WebFileDatabase.m
index 34b2329..1d15b65 100644
--- a/WebKit/Misc.subproj/WebFileDatabase.m
+++ b/WebKit/Misc.subproj/WebFileDatabase.m
@@ -379,6 +379,8 @@ static void URLFileReaderInit(void)
         free(buf);
         close(fd);
     }
+
+    WEBFOUNDATIONDEBUGLEVEL(WebFoundationLogDiskCacheActivity, "writing size file - %u", value);
     
     [mutex unlock];
 }
@@ -553,10 +555,12 @@ static void databaseInit()
     [mutex lock];
     [setCache removeAllObjects];
     [removeCache removeAllObjects];
+    [ops removeAllObjects];
     [self close];
     [[NSFileManager defaultManager] _IF_backgroundRemoveFileAtPath:path];
     [self open];
     [self writeSizeFile:0];
+    usage = 0;
     [mutex unlock];
 
     WEBFOUNDATIONDEBUGLEVEL(WebFoundationLogDiskCacheActivity, "removeAllObjects");
@@ -637,6 +641,8 @@ static void databaseInit()
     NSDictionary *directoryAttributes;
     NSArchiver *archiver;
     NSFileManager *defaultManager;
+    NSNumber *oldSize;
+    BOOL result;
 
     WEBFOUNDATION_ASSERT_NOT_NIL(object);
     WEBFOUNDATION_ASSERT_NOT_NIL(key);
@@ -664,15 +670,26 @@ static void databaseInit()
     defaultManager = [NSFileManager defaultManager];
 
     filePath = [[NSString alloc] initWithFormat:@"%@/%@", path, [IFURLFileDatabase uniqueFilePathForKey:key]];
+    attributes = [defaultManager fileAttributesAtPath:filePath traverseLink:YES];
+
+    result = [defaultManager _IF_createFileAtPathWithIntermediateDirectories:filePath contents:data attributes:attributes directoryAttributes:directoryAttributes];
 
-    [defaultManager _IF_createFileAtPathWithIntermediateDirectories:filePath contents:data attributes:attributes directoryAttributes:directoryAttributes];
+    if (result) {
+        // we're going to write a new file
+        // if there was an old file, we have to subtract the size of the old file before adding the new size
+        if (attributes) {
+            oldSize = [attributes objectForKey:NSFileSize];
+            if (oldSize) {
+                usage -= [oldSize unsignedIntValue];
+            }
+        }
+        usage += [data length];
+        [self writeSizeFile:usage];
+        [self truncateToSizeLimit:[self sizeLimit]];
+    }
 
     [archiver release];
-    [filePath release];
-    
-    usage += [data length];
-    [self writeSizeFile:usage];
-    [self truncateToSizeLimit:[self sizeLimit]];
+    [filePath release];    
 }
 
 -(void)performRemoveObjectForKey:(id)key
@@ -680,6 +697,7 @@ static void databaseInit()
     NSString *filePath;
     NSDictionary *attributes;
     NSNumber *size;
+    BOOL result;
     
     WEBFOUNDATION_ASSERT_NOT_NIL(key);
     
@@ -687,14 +705,14 @@ static void databaseInit()
 
     filePath = [[NSString alloc] initWithFormat:@"%@/%@", path, [IFURLFileDatabase uniqueFilePathForKey:key]];
     attributes = [[NSFileManager defaultManager] fileAttributesAtPath:filePath traverseLink:YES];
-    if (attributes) {
+    result = [[NSFileManager defaultManager] removeFileAtPath:filePath handler:nil];
+    if (result && attributes) {
         size = [attributes objectForKey:NSFileSize];
         if (size) {
             usage -= [size unsignedIntValue];
             [self writeSizeFile:usage];
         }
     }
-    [[NSFileManager defaultManager] removeFileAtPath:filePath handler:nil];
     [filePath release];
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list