Title: [290239] trunk
- Revision
- 290239
- Author
- [email protected]
- Date
- 2022-02-21 01:23:39 -0800 (Mon, 21 Feb 2022)
Log Message
Fetching website data may get wrong record after migrating data to general storage directory
https://bugs.webkit.org/show_bug.cgi?id=236905
Reviewed by Chris Dumez.
Source/WebKit:
To decide if an origin has data, we need to not only check if its directory exists but also if the directory is
empty.
Modified existing test to add test coverage.
* NetworkProcess/storage/OriginStorageManager.cpp:
(WebKit::OriginStorageManager::StorageBucket::resolvedLocalStoragePath):
(WebKit::OriginStorageManager::StorageBucket::resolvedIDBStoragePath): directory should be created before moving
files.
(WebKit::OriginStorageManager::StorageBucket::fetchDataTypesInListFromDisk): given that IndexedDB and
LocalStorage can have custom paths, we may just check data by type.
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (290238 => 290239)
--- trunk/Source/WebKit/ChangeLog 2022-02-21 03:55:04 UTC (rev 290238)
+++ trunk/Source/WebKit/ChangeLog 2022-02-21 09:23:39 UTC (rev 290239)
@@ -1,3 +1,22 @@
+2022-02-21 Sihui Liu <[email protected]>
+
+ Fetching website data may get wrong record after migrating data to general storage directory
+ https://bugs.webkit.org/show_bug.cgi?id=236905
+
+ Reviewed by Chris Dumez.
+
+ To decide if an origin has data, we need to not only check if its directory exists but also if the directory is
+ empty.
+
+ Modified existing test to add test coverage.
+
+ * NetworkProcess/storage/OriginStorageManager.cpp:
+ (WebKit::OriginStorageManager::StorageBucket::resolvedLocalStoragePath):
+ (WebKit::OriginStorageManager::StorageBucket::resolvedIDBStoragePath): directory should be created before moving
+ files.
+ (WebKit::OriginStorageManager::StorageBucket::fetchDataTypesInListFromDisk): given that IndexedDB and
+ LocalStorage can have custom paths, we may just check data by type.
+
2022-02-19 Jon Lee <[email protected]>
Turn WebGL in GPU Process on by default
Modified: trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp (290238 => 290239)
--- trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp 2022-02-21 03:55:04 UTC (rev 290238)
+++ trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp 2022-02-21 09:23:39 UTC (rev 290239)
@@ -258,7 +258,7 @@
FileSystem::excludeFromBackup(localStorageDirectory);
auto localStoragePath = LocalStorageManager::localStorageFilePath(localStorageDirectory);
- if (!m_customLocalStoragePath.isEmpty() && !FileSystem::fileExists(localStoragePath))
+ if (!m_customLocalStoragePath.isEmpty() && !FileSystem::fileExists(localStoragePath) && FileSystem::fileExists(m_customLocalStoragePath))
WebCore::SQLiteFileSystem::moveDatabaseFile(m_customLocalStoragePath, localStoragePath);
m_resolvedLocalStoragePath = localStoragePath;
@@ -280,9 +280,9 @@
m_resolvedIDBStoragePath = m_customIDBStoragePath;
} else {
auto idbStoragePath = typeStoragePath(StorageType::IndexedDB);
- if (!m_customIDBStoragePath.isEmpty() && !FileSystem::fileExists(idbStoragePath)) {
+ if (!m_customIDBStoragePath.isEmpty() && !FileSystem::fileExists(idbStoragePath) && FileSystem::fileExists(m_customIDBStoragePath)) {
+ FileSystem::makeAllDirectories(idbStoragePath);
FileSystem::moveFile(m_customIDBStoragePath, idbStoragePath);
- FileSystem::makeAllDirectories(idbStoragePath);
}
m_resolvedIDBStoragePath = idbStoragePath;
@@ -317,17 +317,18 @@
OptionSet<WebsiteDataType> fetchDataTypesInListFromDisk(OptionSet<WebsiteDataType> types)
{
OptionSet<WebsiteDataType> result;
- for (auto& storageType : FileSystem::listDirectory(m_rootPath)) {
- if (auto type = toWebsiteDataType(storageType); type && types.contains(*type))
- result.add(*type);
+ if (types.contains(WebsiteDataType::FileSystem)) {
+ auto fileSystemStoragePath = typeStoragePath(StorageType::FileSystem);
+ if (auto files = FileSystem::listDirectory(fileSystemStoragePath); !files.isEmpty())
+ result.add(WebsiteDataType::FileSystem);
}
- if (types.contains(WebsiteDataType::LocalStorage) && !result.contains(WebsiteDataType::LocalStorage)) {
+ if (types.contains(WebsiteDataType::LocalStorage)) {
if (FileSystem::fileExists(resolvedLocalStoragePath()))
result.add(WebsiteDataType::LocalStorage);
}
- if (types.contains(WebsiteDataType::IndexedDBDatabases) && !result.contains(WebsiteDataType::IndexedDBDatabases)) {
+ if (types.contains(WebsiteDataType::IndexedDBDatabases)) {
if (auto databases = FileSystem::listDirectory(resolvedIDBStoragePath()); !databases.isEmpty())
result.add(WebsiteDataType::IndexedDBDatabases);
}
Modified: trunk/Tools/ChangeLog (290238 => 290239)
--- trunk/Tools/ChangeLog 2022-02-21 03:55:04 UTC (rev 290238)
+++ trunk/Tools/ChangeLog 2022-02-21 09:23:39 UTC (rev 290239)
@@ -1,3 +1,13 @@
+2022-02-21 Sihui Liu <[email protected]>
+
+ Fetching website data may get wrong record after migrating data to general storage directory
+ https://bugs.webkit.org/show_bug.cgi?id=236905
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+ (TEST):
+
2022-02-20 Sihui Liu <[email protected]>
Origin file may not be created after migrating data to general storage directory
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm (290238 => 290239)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm 2022-02-21 03:55:04 UTC (rev 290238)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm 2022-02-21 09:23:39 UTC (rev 290239)
@@ -1082,4 +1082,12 @@
// Ensure apple.com data is not just moved but actually deleted.
EXPECT_FALSE([fileManager fileExistsAtPath:appleGeneralLocalStorageFile.path]);
EXPECT_FALSE([fileManager fileExistsAtPath:appleGeneralIndexedDBDatabaseFile.path]);
+
+ // Ensure data records do not exist after deletion.
+ done = false;
+ [websiteDataStore fetchDataRecordsOfTypes:dataTypes completionHandler:^(NSArray<WKWebsiteDataRecord *> *records) {
+ EXPECT_EQ(records.count, 0u);
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes