Title: [87704] trunk/Source/WebCore
Revision
87704
Author
eric.carl...@apple.com
Date
2011-05-30 18:44:55 -0700 (Mon, 30 May 2011)

Log Message

2011-05-30  Eric Carlson  <eric.carl...@apple.com>

        Reviewed by Alexey Proskuryakov.

        Audio and video files saved to the Application Cache should preserve the original file extension
        https://bugs.webkit.org/show_bug.cgi?id=61750
        <rdar://9524922>

        No new tests, it isn't possible to check the name of the file in the cache from within
        DRT. Changes verified manually.

        * loader/appcache/ApplicationCacheStorage.cpp:
        (WebCore::ApplicationCacheStorage::store): Append the original file extension to the cache
            file name.
        (WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory): Add extension parameter.
        * loader/appcache/ApplicationCacheStorage.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87703 => 87704)


--- trunk/Source/WebCore/ChangeLog	2011-05-31 00:05:02 UTC (rev 87703)
+++ trunk/Source/WebCore/ChangeLog	2011-05-31 01:44:55 UTC (rev 87704)
@@ -1,3 +1,20 @@
+2011-05-30  Eric Carlson  <eric.carl...@apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Audio and video files saved to the Application Cache should preserve the original file extension
+        https://bugs.webkit.org/show_bug.cgi?id=61750
+        <rdar://9524922>
+
+        No new tests, it isn't possible to check the name of the file in the cache from within
+        DRT. Changes verified manually.
+
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::store): Append the original file extension to the cache
+            file name.
+        (WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory): Add extension parameter.
+        * loader/appcache/ApplicationCacheStorage.h:
+
 2011-05-30  Jer Noble  <jer.no...@apple.com>
 
         Reviewed by Dan Bernstein.

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp (87703 => 87704)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2011-05-31 00:05:02 UTC (rev 87703)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2011-05-31 01:44:55 UTC (rev 87704)
@@ -803,8 +803,16 @@
         
         String flatFileDirectory = pathByAppendingComponent(m_cacheDirectory, flatFileSubdirectory);
         makeAllDirectories(flatFileDirectory);
+
+        String extension;
+        
+        String fileName = resource->response().suggestedFilename();
+        size_t dotIndex = fileName.reverseFind('.');
+        if (dotIndex != notFound && dotIndex < (fileName.length() - 1))
+            extension = fileName.substring(dotIndex);
+
         String path;
-        if (!writeDataToUniqueFileInDirectory(resource->data(), flatFileDirectory, path))
+        if (!writeDataToUniqueFileInDirectory(resource->data(), flatFileDirectory, path, extension))
             return false;
         
         fullPath = pathByAppendingComponent(flatFileDirectory, path);
@@ -1231,12 +1239,12 @@
         || resource->response().mimeType().startsWith("video/", false);
 }
     
-bool ApplicationCacheStorage::writeDataToUniqueFileInDirectory(SharedBuffer* data, const String& directory, String& path)
+bool ApplicationCacheStorage::writeDataToUniqueFileInDirectory(SharedBuffer* data, const String& directory, String& path, const String& fileExtension)
 {
     String fullPath;
     
     do {
-        path = encodeForFileName(createCanonicalUUIDString());
+        path = encodeForFileName(createCanonicalUUIDString()) + fileExtension;
         // Guard against the above function being called on a platform which does not implement
         // createCanonicalUUIDString().
         ASSERT(!path.isEmpty());

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h (87703 => 87704)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h	2011-05-31 00:05:02 UTC (rev 87703)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h	2011-05-31 01:44:55 UTC (rev 87704)
@@ -115,7 +115,7 @@
     bool ensureOriginRecord(const SecurityOrigin*);
     bool shouldStoreResourceAsFlatFile(ApplicationCacheResource*);
     void deleteTables();
-    bool writeDataToUniqueFileInDirectory(SharedBuffer*, const String& directory, String& outFilename);
+    bool writeDataToUniqueFileInDirectory(SharedBuffer*, const String& directory, String& outFilename, const String& fileExtension);
 
     void loadManifestHostHashes();
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to