Diff
Modified: trunk/Source/WebCore/ChangeLog (291785 => 291786)
--- trunk/Source/WebCore/ChangeLog 2022-03-24 05:33:58 UTC (rev 291785)
+++ trunk/Source/WebCore/ChangeLog 2022-03-24 06:25:20 UTC (rev 291786)
@@ -1,3 +1,14 @@
+2022-03-23 Sihui Liu <[email protected]>
+
+ Add logging for LocalStorage and IndexedDB data migration
+ https://bugs.webkit.org/show_bug.cgi?id=238169
+
+ Reviewed by Chris Dumez.
+
+ * platform/sql/SQLiteFileSystem.cpp:
+ (WebCore::SQLiteFileSystem::moveDatabaseFile):
+ * platform/sql/SQLiteFileSystem.h:
+
2022-03-23 Alex Christensen <[email protected]>
Add off-by-default experimental feature for app store attribution
Modified: trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp (291785 => 291786)
--- trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp 2022-03-24 05:33:58 UTC (rev 291785)
+++ trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp 2022-03-24 06:25:20 UTC (rev 291786)
@@ -91,10 +91,13 @@
return !fileExists;
}
-void SQLiteFileSystem::moveDatabaseFile(const String& oldFilePath, const String& newFilePath)
+bool SQLiteFileSystem::moveDatabaseFile(const String& oldFilePath, const String& newFilePath)
{
+ bool allMoved = true;
for (const auto* suffix : databaseFileSuffixes)
- FileSystem::moveFile(makeString(oldFilePath, suffix), makeString(newFilePath, suffix));
+ allMoved &= FileSystem::moveFile(makeString(oldFilePath, suffix), makeString(newFilePath, suffix));
+
+ return allMoved;
}
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h (291785 => 291786)
--- trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h 2022-03-24 05:33:58 UTC (rev 291785)
+++ trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h 2022-03-24 06:25:20 UTC (rev 291786)
@@ -81,7 +81,7 @@
WEBCORE_EXPORT static bool deleteDatabaseFile(const String& filePath);
// Moves a database file to a new place.
- WEBCORE_EXPORT static void moveDatabaseFile(const String& oldFilePath, const String& newFilePath);
+ WEBCORE_EXPORT static bool moveDatabaseFile(const String& oldFilePath, const String& newFilePath);
WEBCORE_EXPORT static String computeHashForFileName(const String& filePath);
#if PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebKit/ChangeLog (291785 => 291786)
--- trunk/Source/WebKit/ChangeLog 2022-03-24 05:33:58 UTC (rev 291785)
+++ trunk/Source/WebKit/ChangeLog 2022-03-24 06:25:20 UTC (rev 291786)
@@ -1,3 +1,18 @@
+2022-03-23 Sihui Liu <[email protected]>
+
+ Add logging for LocalStorage and IndexedDB data migration
+ https://bugs.webkit.org/show_bug.cgi?id=238169
+
+ Reviewed by Chris Dumez.
+
+ * NetworkProcess/storage/IDBStorageManager.cpp:
+ (WebKit::migrateOriginDataImpl):
+ (WebKit::IDBStorageManager::migrateOriginData):
+ * NetworkProcess/storage/IDBStorageManager.h:
+ * NetworkProcess/storage/OriginStorageManager.cpp:
+ (WebKit::OriginStorageManager::StorageBucket::resolvedLocalStoragePath):
+ (WebKit::OriginStorageManager::StorageBucket::resolvedIDBStoragePath):
+
2022-03-23 Simon Fraser <[email protected]>
Have MiniBrowser shows the GPU Process pid in its title bar
Modified: trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp (291785 => 291786)
--- trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp 2022-03-24 05:33:58 UTC (rev 291785)
+++ trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp 2022-03-24 06:25:20 UTC (rev 291786)
@@ -35,18 +35,19 @@
namespace WebKit {
-static void migrateOriginDataImpl(const String& oldOriginDirectory, const String& newOriginDirectory, Function<String(const String&)>&& createFileNameFunction)
+static bool migrateOriginDataImpl(const String& oldOriginDirectory, const String& newOriginDirectory, Function<String(const String&)>&& createFileNameFunction)
{
if (oldOriginDirectory.isEmpty() || !FileSystem::fileExists(oldOriginDirectory))
- return;
+ return true;
auto fileNames = FileSystem::listDirectory(oldOriginDirectory);
if (fileNames.isEmpty()) {
FileSystem::deleteEmptyDirectory(oldOriginDirectory);
- return;
+ return true;
}
FileSystem::makeAllDirectories(newOriginDirectory);
+ bool allMoved = true;
for (auto& name : fileNames) {
// This is an origin directory for third-party data.
if (auto origin = WebCore::SecurityOriginData::fromDatabaseIdentifier(name))
@@ -58,10 +59,11 @@
continue;
auto oldPath = FileSystem::pathByAppendingComponent(oldOriginDirectory, name);
- FileSystem::moveFile(oldPath, newPath);
+ allMoved &= FileSystem::moveFile(oldPath, newPath);
}
FileSystem::deleteEmptyDirectory(oldOriginDirectory);
+ return allMoved;
}
String IDBStorageManager::idbStorageOriginDirectory(const String& rootDirectory, const WebCore::ClientOrigin& origin)
@@ -126,9 +128,9 @@
return origins;
}
-void IDBStorageManager::migrateOriginData(const String& oldOriginDirectory, const String& newOriginDirectory)
+bool IDBStorageManager::migrateOriginData(const String& oldOriginDirectory, const String& newOriginDirectory)
{
- migrateOriginDataImpl(oldOriginDirectory, newOriginDirectory, [](const String& name) {
+ return migrateOriginDataImpl(oldOriginDirectory, newOriginDirectory, [](const String& name) {
return name;
});
}
Modified: trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.h (291785 => 291786)
--- trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.h 2022-03-24 05:33:58 UTC (rev 291785)
+++ trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.h 2022-03-24 06:25:20 UTC (rev 291786)
@@ -49,7 +49,7 @@
static String idbStorageOriginDirectory(const String& rootDirectory, const WebCore::ClientOrigin&);
static uint64_t idbStorageSize(const String& originDirectory);
static HashSet<WebCore::ClientOrigin> originsOfIDBStorageData(const String& rootDirectory);
- static void migrateOriginData(const String& oldOriginDirectory, const String& newOriginDirectory);
+ static bool migrateOriginData(const String& oldOriginDirectory, const String& newOriginDirectory);
using QuotaCheckFunction = Function<void(uint64_t spaceRequested, CompletionHandler<void(bool)>&&)>;
IDBStorageManager(const String& path, IDBStorageRegistry&, QuotaCheckFunction&&);
Modified: trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp (291785 => 291786)
--- trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp 2022-03-24 05:33:58 UTC (rev 291785)
+++ trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp 2022-03-24 06:25:20 UTC (rev 291786)
@@ -32,6 +32,7 @@
#include "IDBStorageManager.h"
#include "IDBStorageRegistry.h"
#include "LocalStorageManager.h"
+#include "Logging.h"
#include "MemoryStorageArea.h"
#include "SessionStorageManager.h"
#include "StorageAreaRegistry.h"
@@ -353,8 +354,12 @@
auto localStorageDirectory = typeStoragePath(StorageType::LocalStorage);
FileSystem::makeAllDirectories(localStorageDirectory);
auto localStoragePath = LocalStorageManager::localStorageFilePath(localStorageDirectory);
- if (!m_customLocalStoragePath.isEmpty() && !FileSystem::fileExists(localStoragePath) && FileSystem::fileExists(m_customLocalStoragePath))
- WebCore::SQLiteFileSystem::moveDatabaseFile(m_customLocalStoragePath, localStoragePath);
+ if (!m_customLocalStoragePath.isEmpty() && !FileSystem::fileExists(localStoragePath) && FileSystem::fileExists(m_customLocalStoragePath)) {
+ RELEASE_LOG(Storage, "%p - StorageBucket::resolvedLocalStoragePath New path '%{public}s'", this, localStoragePath.utf8().data());
+ auto moved = WebCore::SQLiteFileSystem::moveDatabaseFile(m_customLocalStoragePath, localStoragePath);
+ if (!moved && !FileSystem::fileExists(localStoragePath))
+ RELEASE_LOG_ERROR(Storage, "%p - StorageBucket::resolvedLocalStoragePath Fails to migrate file to new path", this);
+ }
m_resolvedLocalStoragePath = localStoragePath;
} else
@@ -381,7 +386,13 @@
m_resolvedIDBStoragePath = m_customIDBStoragePath;
} else {
auto idbStoragePath = typeStoragePath(StorageType::IndexedDB);
- IDBStorageManager::migrateOriginData(m_customIDBStoragePath, idbStoragePath);
+ RELEASE_LOG(Storage, "%p - StorageBucket::resolvedIDBStoragePath New path '%{public}s'", this, idbStoragePath.utf8().data());
+ auto moved = IDBStorageManager::migrateOriginData(m_customIDBStoragePath, idbStoragePath);
+ if (!moved && FileSystem::fileExists(idbStoragePath)) {
+ auto fileNames = FileSystem::listDirectory(m_customIDBStoragePath);
+ auto newFileNames = FileSystem::listDirectory(idbStoragePath);
+ RELEASE_LOG_ERROR(Storage, "%p - StorageBucket::resolvedLocalStoragePath Fails to migrate all databases to new path: %zu migrated, %zu left", this, newFileNames.size(), fileNames.size());
+ }
m_resolvedIDBStoragePath = idbStoragePath;
}