Title: [204041] trunk
- Revision
- 204041
- Author
- beid...@apple.com
- Date
- 2016-08-02 14:28:12 -0700 (Tue, 02 Aug 2016)
Log Message
Removing IndexedDB WebsiteData can fail for some users.
https://bugs.webkit.org/show_bug.cgi?id=160463
Reviewed by Alex Christensen.
Source/WebCore:
Covered by changes to API test IndexedDB.StoreBlobThenDelete.
For a few months in trunk WebKit, deleting an IndexedDB using WebsiteDataStore API would only
delete the "IndexedDB.sqlite3" file, but would leave the "-wal" and "-shm" files behind.
We'd then fail to delete the directory itself, tricking API clients to think there are still
databases in the given origin.
Furthermore, the code to delete a database first checks for the existence of "IndexedDB.sqlite3"
then refuses to do any further cleanup if it doesn't exist.
We should just always run the entire delete procedure even if IndexedDB.sqlite does not exist.
* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::removeAllDatabasesForOriginPath):
* platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::deleteDatabaseFile):
Tools:
* TestWebKitAPI/Tests/WebKit2Cocoa/StoreBlobThenDelete.mm:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (204040 => 204041)
--- trunk/Source/WebCore/ChangeLog 2016-08-02 21:17:37 UTC (rev 204040)
+++ trunk/Source/WebCore/ChangeLog 2016-08-02 21:28:12 UTC (rev 204041)
@@ -1,3 +1,29 @@
+2016-08-02 Brady Eidson <beid...@apple.com>
+
+ Removing IndexedDB WebsiteData can fail for some users.
+ https://bugs.webkit.org/show_bug.cgi?id=160463
+
+ Reviewed by Alex Christensen.
+
+ Covered by changes to API test IndexedDB.StoreBlobThenDelete.
+
+ For a few months in trunk WebKit, deleting an IndexedDB using WebsiteDataStore API would only
+ delete the "IndexedDB.sqlite3" file, but would leave the "-wal" and "-shm" files behind.
+
+ We'd then fail to delete the directory itself, tricking API clients to think there are still
+ databases in the given origin.
+
+ Furthermore, the code to delete a database first checks for the existence of "IndexedDB.sqlite3"
+ then refuses to do any further cleanup if it doesn't exist.
+
+ We should just always run the entire delete procedure even if IndexedDB.sqlite does not exist.
+
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::removeAllDatabasesForOriginPath):
+
+ * platform/sql/SQLiteFileSystem.cpp:
+ (WebCore::SQLiteFileSystem::deleteDatabaseFile):
+
2016-08-02 Alex Christensen <achristen...@webkit.org>
Fix Mac CMake build.
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (204040 => 204041)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2016-08-02 21:17:37 UTC (rev 204040)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2016-08-02 21:28:12 UTC (rev 204041)
@@ -543,10 +543,7 @@
for (auto& databasePath : databasePaths) {
String databaseFile = pathByAppendingComponent(databasePath, "IndexedDB.sqlite3");
- if (!fileExists(databaseFile))
- continue;
-
- if (modifiedSince > std::chrono::system_clock::time_point::min()) {
+ if (modifiedSince > std::chrono::system_clock::time_point::min() && fileExists(databaseFile)) {
time_t modificationTime;
if (!getFileModificationTime(databaseFile, modificationTime))
continue;
Modified: trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp (204040 => 204041)
--- trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp 2016-08-02 21:17:37 UTC (rev 204040)
+++ trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp 2016-08-02 21:28:12 UTC (rev 204041)
@@ -88,15 +88,13 @@
String walFileName = makeString(fileName, ASCIILiteral("-wal"));
String shmFileName = makeString(fileName, ASCIILiteral("-shm"));
- if (!deleteFile(fileName))
- return false;
-
- // Try to delete both the wal and shm files, whether or not they are actually there.
+ // Try to delete all three files whether or not they are there.
+ deleteFile(fileName);
deleteFile(walFileName);
deleteFile(shmFileName);
- // If either the wal or shm files remain after the delete attempt, the overall delete operation failed.
- return !fileExists(walFileName) && !fileExists(shmFileName);
+ // If any of the wal or shm files remain after the delete attempt, the overall delete operation failed.
+ return !fileExists(fileName) && !fileExists(walFileName) && !fileExists(shmFileName);
}
#if PLATFORM(IOS)
Modified: trunk/Tools/ChangeLog (204040 => 204041)
--- trunk/Tools/ChangeLog 2016-08-02 21:17:37 UTC (rev 204040)
+++ trunk/Tools/ChangeLog 2016-08-02 21:28:12 UTC (rev 204041)
@@ -1,3 +1,12 @@
+2016-08-02 Brady Eidson <beid...@apple.com>
+
+ Removing IndexedDB WebsiteData can fail for some users.
+ https://bugs.webkit.org/show_bug.cgi?id=160463
+
+ Reviewed by Alex Christensen.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/StoreBlobThenDelete.mm:
+
2016-08-01 Alex Christensen <achristen...@webkit.org>
_WKDownloadDelegate.didReceiveResponse should be called before decideDestinationWithSuggestedFilename
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/StoreBlobThenDelete.mm (204040 => 204041)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/StoreBlobThenDelete.mm 2016-08-02 21:17:37 UTC (rev 204040)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/StoreBlobThenDelete.mm 2016-08-02 21:28:12 UTC (rev 204041)
@@ -74,6 +74,18 @@
EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:blobFilePath]);
EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
+ // To make sure that the -wal and -shm files for a database are deleted even if the sqlite3 file is already missing,
+ // we need to:
+ // 1 - Create the path for a fake database that won't actively be in use
+ // 2 - Move -wal and -shm files into that directory
+ // 3 - Make sure the entire directory is deleted
+ NSString *fakeDatabasePath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/FakeDatabasePath" stringByExpandingTildeInPath];
+ NSString *fakeShmPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/FakeDatabasePath/IndexedDB.sqlite3-wal" stringByExpandingTildeInPath];
+ NSString *fakeWalPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/FakeDatabasePath/IndexedDB.sqlite3-shm" stringByExpandingTildeInPath];
+ [[NSFileManager defaultManager] createDirectoryAtPath:fakeDatabasePath withIntermediateDirectories:NO attributes:nil error:nil];
+ [[NSFileManager defaultManager] copyItemAtPath:databaseFilePath toPath:fakeShmPath error:nil];
+ [[NSFileManager defaultManager] copyItemAtPath:databaseFilePath toPath:fakeWalPath error:nil];
+
// Make some other .blob files in the database directory to later validate that only appropriate files are deleted.
NSString *otherBlob1 = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/StoreBlobToBeDeleted/7182.blob" stringByExpandingTildeInPath];
NSString *otherBlob2 = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/StoreBlobToBeDeleted/1a.blob" stringByExpandingTildeInPath];
@@ -97,6 +109,11 @@
EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:otherBlob3]);
EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:otherBlob4]);
+ // Make sure everything related to the fake database is gone.
+ EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fakeShmPath]);
+ EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fakeWalPath]);
+ EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fakeDatabasePath]);
+
// Now delete them so we're not leaving files around.
[[NSFileManager defaultManager] removeItemAtPath:otherBlob2 error:nil];
[[NSFileManager defaultManager] removeItemAtPath:otherBlob3 error:nil];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes