Changeset 243019 in webkit
- Timestamp:
- Mar 15, 2019 3:32:38 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243017 r243019 1 2019-03-15 Sihui Liu <sihui_liu@apple.com> 2 3 [ Mojave WK1 ] Layout Test storage/indexeddb/database-odd-names.html is failing 4 https://bugs.webkit.org/show_bug.cgi?id=190350 5 <rdar://problem/45089503> 6 7 Reviewed by Geoffrey Garen. 8 9 Start to use hash for database file names so that the files can work on any filesystem. 10 11 We created v0 folder in IndexedDB directory to put the legacy databases, and v1 folder to put the upgraded 12 databases. 13 14 Tests: TestWebKitAPI.IndexedDB.IndexedDBFileName 15 TestWebKitAPI.IndexedDB.IndexedDBFileNameV0 16 TestWebKitAPI.IndexedDB.IndexedDBFileNameV1 17 TestWebKitAPI.IndexedDB.IndexedDBFileNameAPI 18 TestWebKitAPI.IndexedDB.HashCollision 19 20 * Modules/indexeddb/IDBDatabaseIdentifier.cpp: 21 (WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot const): 22 (WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot): 23 * Modules/indexeddb/IDBDatabaseIdentifier.h: 24 * Modules/indexeddb/server/IDBServer.cpp: 25 (WebCore::IDBServer::m_quotaManagerGetter): 26 (WebCore::IDBServer::IDBServer::performGetAllDatabaseNames): 27 (WebCore::IDBServer::removeAllDatabasesForFullOriginPath): 28 (WebCore::IDBServer::removeAllDatabasesForOriginPath): 29 (WebCore::IDBServer::IDBServer::removeDatabasesModifiedSinceForVersion): 30 (WebCore::IDBServer::IDBServer::performCloseAndDeleteDatabasesModifiedSince): 31 (WebCore::IDBServer::IDBServer::removeDatabasesWithOriginsForVersion): 32 (WebCore::IDBServer::IDBServer::performCloseAndDeleteDatabasesForOrigins): 33 (WebCore::IDBServer::IDBServer::computeSpaceUsedForOrigin): 34 (WebCore::IDBServer::IDBServer::upgradeFilesIfNecessary): 35 * Modules/indexeddb/server/IDBServer.h: 36 * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: 37 (WebCore::IDBServer::SQLiteIDBBackingStore::SQLiteIDBBackingStore): 38 (WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabasePathForDirectory): 39 (WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabasePath const): 40 (WebCore::IDBServer::SQLiteIDBBackingStore::databaseNameFromFile): 41 (WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabaseDirectoryWithUpgrade): 42 (WebCore::IDBServer::SQLiteIDBBackingStore::getOrEstablishDatabaseInfo): 43 (WebCore::IDBServer::SQLiteIDBBackingStore::quotaForOrigin const): 44 (WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForOrigin const): 45 (WebCore::IDBServer::SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord): 46 (WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore): 47 (WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabaseDirectory const): Deleted. 48 * Modules/indexeddb/server/SQLiteIDBBackingStore.h: 49 (WebCore::IDBServer::SQLiteIDBBackingStore::databaseDirectory const): 50 * Modules/indexeddb/server/SQLiteIDBTransaction.cpp: 51 (WebCore::IDBServer::SQLiteIDBTransaction::moveBlobFilesIfNecessary): 52 (WebCore::IDBServer::SQLiteIDBTransaction::deleteBlobFilesIfNecessary): 53 * platform/sql/SQLiteFileSystem.cpp: 54 (WebCore::SQLiteFileSystem::computeHashForFileName): 55 * platform/sql/SQLiteFileSystem.h: 56 1 57 2019-03-15 Zalan Bujtas <zalan@apple.com> 2 58 -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp
r242729 r243019 56 56 } 57 57 58 String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const String& rootDirectory ) const58 String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const String& rootDirectory, const String& versionString) const 59 59 { 60 return databaseDirectoryRelativeToRoot(m_origin.topOrigin, m_origin.clientOrigin, rootDirectory );60 return databaseDirectoryRelativeToRoot(m_origin.topOrigin, m_origin.clientOrigin, rootDirectory, versionString); 61 61 } 62 62 63 String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const SecurityOriginData& topLevelOrigin, const SecurityOriginData& openingOrigin, const String& rootDirectory )63 String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const SecurityOriginData& topLevelOrigin, const SecurityOriginData& openingOrigin, const String& rootDirectory, const String& versionString) 64 64 { 65 String mainFrameDirectory = FileSystem::pathByAppendingComponent(rootDirectory, topLevelOrigin.databaseIdentifier()); 65 String versionDirectory = FileSystem::pathByAppendingComponent(rootDirectory, versionString); 66 String mainFrameDirectory = FileSystem::pathByAppendingComponent(versionDirectory, topLevelOrigin.databaseIdentifier()); 66 67 67 68 // If the opening origin and main frame origins are the same, there is no partitioning. -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h
r242729 r243019 85 85 const ClientOrigin& origin() const { return m_origin; } 86 86 87 String databaseDirectoryRelativeToRoot(const String& rootDirectory ) const;88 static String databaseDirectoryRelativeToRoot(const SecurityOriginData& topLevelOrigin, const SecurityOriginData& openingOrigin, const String& rootDirectory );87 String databaseDirectoryRelativeToRoot(const String& rootDirectory, const String& versionString="v1") const; 88 static String databaseDirectoryRelativeToRoot(const SecurityOriginData& topLevelOrigin, const SecurityOriginData& openingOrigin, const String& rootDirectory, const String& versionString); 89 89 90 90 template<class Encoder> void encode(Encoder&) const; -
trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp
r242947 r243019 33 33 #include "Logging.h" 34 34 #include "MemoryIDBBackingStore.h" 35 #include "SQLiteDatabase.h" 35 36 #include "SQLiteFileSystem.h" 36 37 #include "SQLiteIDBBackingStore.h" 38 #include "SQLiteStatement.h" 37 39 #include "SecurityOrigin.h" 38 40 #include "StorageQuotaManager.h" … … 74 76 { 75 77 LOG(IndexedDB, "IDBServer created at path %s", databaseDirectoryPath.utf8().data()); 78 postDatabaseTask(createCrossThreadTask(*this, &IDBServer::upgradeFilesIfNecessary)); 76 79 } 77 80 … … 467 470 void IDBServer::performGetAllDatabaseNames(uint64_t serverConnectionIdentifier, const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID) 468 471 { 469 String directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(mainFrameOrigin, openingOrigin, m_databaseDirectoryPath); 470 471 Vector<String> entries = FileSystem::listDirectory(directory, "*"_s); 472 String oldDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(mainFrameOrigin, openingOrigin, m_databaseDirectoryPath, "v0"); 473 Vector<String> files = FileSystem::listDirectory(oldDirectory, "*"_s); 472 474 Vector<String> databases; 473 databases.reserveInitialCapacity(entries.size()); 474 for (auto& entry : entries) { 475 String encodedName = FileSystem::lastComponentOfPathIgnoringTrailingSlash(entry); 476 databases.uncheckedAppend(SQLiteIDBBackingStore::databaseNameFromEncodedFilename(encodedName)); 475 for (auto& file : files) { 476 String encodedName = FileSystem::lastComponentOfPathIgnoringTrailingSlash(file); 477 databases.append(SQLiteIDBBackingStore::databaseNameFromEncodedFilename(encodedName)); 478 } 479 480 String directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(mainFrameOrigin, openingOrigin, m_databaseDirectoryPath, "v1"); 481 files = FileSystem::listDirectory(directory, "*"_s); 482 for (auto& file : files) { 483 auto databaseName = SQLiteIDBBackingStore::databaseNameFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory(file)); 484 if (!databaseName.isEmpty()) 485 databases.append(databaseName); 477 486 } 478 487 … … 551 560 } 552 561 553 static void removeAllDatabasesFor OriginPath(const String& originPath, WallTime modifiedSince)562 static void removeAllDatabasesForFullOriginPath(const String& originPath, WallTime modifiedSince) 554 563 { 555 564 LOG(IndexedDB, "removeAllDatabasesForOriginPath with originPath %s", originPath.utf8().data()); … … 557 566 558 567 for (auto& databasePath : databasePaths) { 559 if (FileSystem::fileIsDirectory(databasePath, FileSystem::ShouldFollowSymbolicLinks::No))560 removeAllDatabasesForOriginPath(databasePath, modifiedSince);561 562 568 String databaseFile = FileSystem::pathByAppendingComponent(databasePath, "IndexedDB.sqlite3"); 563 569 if (modifiedSince > -WallTime::infinity() && FileSystem::fileExists(databaseFile)) { … … 619 625 } 620 626 627 static void removeAllDatabasesForOriginPath(const String& originPath, WallTime modifiedSince) 628 { 629 String databaseIdentifier = FileSystem::lastComponentOfPathIgnoringTrailingSlash(originPath); 630 if (!SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 631 return; 632 633 auto directories = FileSystem::listDirectory(originPath, "*"_s); 634 for (auto& directory : directories) { 635 String databaseIdentifier = FileSystem::lastComponentOfPathIgnoringTrailingSlash(directory); 636 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 637 removeAllDatabasesForFullOriginPath(directory, modifiedSince); 638 } 639 640 removeAllDatabasesForFullOriginPath(originPath, modifiedSince); 641 } 642 643 void IDBServer::removeDatabasesModifiedSinceForVersion(WallTime modifiedSince, const String& version) 644 { 645 String versionPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, version); 646 for (auto& originPath : FileSystem::listDirectory(versionPath, "*")) { 647 String databaseIdentifier = FileSystem::lastComponentOfPathIgnoringTrailingSlash(originPath); 648 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 649 removeAllDatabasesForOriginPath(originPath, modifiedSince); 650 } 651 } 652 621 653 void IDBServer::performCloseAndDeleteDatabasesModifiedSince(WallTime modifiedSince, uint64_t callbackID) 622 654 { 623 655 if (!m_databaseDirectoryPath.isEmpty()) { 624 Vector<String> originPaths = FileSystem::listDirectory(m_databaseDirectoryPath, "*"); 625 for (auto& originPath : originPaths) 626 removeAllDatabasesForOriginPath(originPath, modifiedSince); 656 removeDatabasesModifiedSinceForVersion(modifiedSince, "v0"); 657 removeDatabasesModifiedSinceForVersion(modifiedSince, "v1"); 627 658 } 628 659 … … 630 661 } 631 662 663 void IDBServer::removeDatabasesWithOriginsForVersion(const Vector<SecurityOriginData> &origins, const String& version) 664 { 665 String versionPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, version); 666 for (const auto& origin : origins) { 667 String originPath = FileSystem::pathByAppendingComponent(versionPath, origin.databaseIdentifier()); 668 removeAllDatabasesForOriginPath(originPath, -WallTime::infinity()); 669 670 for (auto& topOriginPath : FileSystem::listDirectory(versionPath, "*")) { 671 originPath = FileSystem::pathByAppendingComponent(topOriginPath, origin.databaseIdentifier()); 672 removeAllDatabasesForOriginPath(originPath, -WallTime::infinity()); 673 } 674 } 675 } 676 632 677 void IDBServer::performCloseAndDeleteDatabasesForOrigins(const Vector<SecurityOriginData>& origins, uint64_t callbackID) 633 678 { 634 679 if (!m_databaseDirectoryPath.isEmpty()) { 635 for (const auto& origin : origins) { 636 String originPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, origin.databaseIdentifier()); 637 removeAllDatabasesForOriginPath(originPath, -WallTime::infinity()); 638 639 for (const auto& topOriginPath : FileSystem::listDirectory(m_databaseDirectoryPath, "*")) { 640 originPath = FileSystem::pathByAppendingComponent(topOriginPath, origin.databaseIdentifier()); 641 removeAllDatabasesForOriginPath(originPath, -WallTime::infinity()); 642 } 643 } 680 removeDatabasesWithOriginsForVersion(origins, "v0"); 681 removeDatabasesWithOriginsForVersion(origins, "v1"); 644 682 } 645 683 … … 764 802 ASSERT(!isMainThread()); 765 803 766 auto path = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath); 767 auto size = SQLiteIDBBackingStore::databasesSizeForFolder(path); 804 auto oldVersionOriginDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath, "v0"); 805 auto newVersionOriginDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath, "v1"); 806 auto size = SQLiteIDBBackingStore::databasesSizeForFolder(oldVersionOriginDirectory) + SQLiteIDBBackingStore::databasesSizeForFolder(newVersionOriginDirectory); 768 807 769 808 postDatabaseTaskReply(createCrossThreadTask(*this, &IDBServer::finishComputingSpaceUsedForOrigin, origin, size)); … … 807 846 } 808 847 848 void IDBServer::upgradeFilesIfNecessary() 849 { 850 if (m_databaseDirectoryPath.isEmpty() || !FileSystem::fileExists(m_databaseDirectoryPath)) 851 return; 852 853 String newVersionDirectory = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, "v1"); 854 if (!FileSystem::fileExists(newVersionDirectory)) 855 FileSystem::makeAllDirectories(newVersionDirectory); 856 } 857 809 858 } // namespace IDBServer 810 859 } // namespace WebCore -
trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h
r242911 r243019 139 139 void didPerformCloseAndDeleteDatabases(uint64_t callbackID); 140 140 141 void upgradeFilesIfNecessary(); 142 void removeDatabasesModifiedSinceForVersion(WallTime, const String&); 143 void removeDatabasesWithOriginsForVersion(const Vector<SecurityOriginData>&, const String&); 144 141 145 class QuotaUser final : public StorageQuotaUser { 142 146 WTF_MAKE_FAST_ALLOCATED; -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
r242911 r243019 233 233 SQLiteIDBBackingStore::SQLiteIDBBackingStore(const IDBDatabaseIdentifier& identifier, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler& fileHandler, uint64_t quota) 234 234 : m_identifier(identifier) 235 , m_databaseRootDirectory(databaseRootDirectory) 235 236 , m_temporaryFileHandler(fileHandler) 236 237 , m_quota(quota) 237 238 { 238 m_ absoluteDatabaseDirectory = identifier.databaseDirectoryRelativeToRoot(databaseRootDirectory);239 m_databaseDirectory = fullDatabaseDirectoryWithUpgrade(); 239 240 } 240 241 … … 765 766 } 766 767 767 String SQLiteIDBBackingStore::fullDatabaseDirectory() const 768 { 769 ASSERT(!m_identifier.databaseName().isNull()); 770 771 return FileSystem::pathByAppendingComponent(m_absoluteDatabaseDirectory, filenameForDatabaseName()); 768 String SQLiteIDBBackingStore::fullDatabasePathForDirectory(const String& fullDatabaseDirectory) 769 { 770 return FileSystem::pathByAppendingComponent(fullDatabaseDirectory, "IndexedDB.sqlite3"); 772 771 } 773 772 774 773 String SQLiteIDBBackingStore::fullDatabasePath() const 775 774 { 776 ASSERT(!m_identifier.databaseName().isNull()); 777 778 return FileSystem::pathByAppendingComponent(fullDatabaseDirectory(), "IndexedDB.sqlite3"); 775 return fullDatabasePathForDirectory(m_databaseDirectory); 776 } 777 778 String SQLiteIDBBackingStore::databaseNameFromFile(const String& databasePath) 779 { 780 SQLiteDatabase database; 781 if (!database.open(databasePath)) { 782 LOG_ERROR("Failed to open SQLite database at path '%s' when getting database name", databasePath.utf8().data()); 783 return { }; 784 } 785 if (!database.tableExists("IDBDatabaseInfo"_s)) { 786 LOG_ERROR("Could not find IDBDatabaseInfo table and get database name(%i) - %s", database.lastError(), database.lastErrorMsg()); 787 database.close(); 788 return { }; 789 } 790 SQLiteStatement sql(database, "SELECT value FROM IDBDatabaseInfo WHERE key = 'DatabaseName';"); 791 auto databaseName = sql.getColumnText(0); 792 database.close(); 793 return databaseName; 794 } 795 796 String SQLiteIDBBackingStore::fullDatabaseDirectoryWithUpgrade() 797 { 798 String oldOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory, "v0"); 799 String oldDatabaseDirectory = FileSystem::pathByAppendingComponent(oldOriginDirectory, filenameForDatabaseName()); 800 String newOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory, "v1"); 801 String fileNameHash = SQLiteFileSystem::computeHashForFileName(m_identifier.databaseName()); 802 Vector<String> directoriesWithSameHash = FileSystem::listDirectory(newOriginDirectory, fileNameHash + "*"); 803 String newDatabaseDirectory = FileSystem::pathByAppendingComponent(newOriginDirectory, fileNameHash); 804 FileSystem::makeAllDirectories(newDatabaseDirectory); 805 806 if (FileSystem::fileExists(oldDatabaseDirectory)) { 807 FileSystem::moveFile(oldDatabaseDirectory, newDatabaseDirectory); 808 FileSystem::deleteEmptyDirectory(oldOriginDirectory); 809 } 810 811 return newDatabaseDirectory; 779 812 } 780 813 … … 788 821 } 789 822 790 FileSystem::makeAllDirectories(fullDatabaseDirectory());791 823 String dbFilename = fullDatabasePath(); 792 824 … … 847 879 ASSERT(!isMainThread()); 848 880 uint64_t diskFreeSpaceSize = 0; 849 FileSystem::getVolumeFreeSpace(m_ absoluteDatabaseDirectory, diskFreeSpaceSize);881 FileSystem::getVolumeFreeSpace(m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory), diskFreeSpaceSize); 850 882 return std::min(diskFreeSpaceSize / 2, m_quota); 851 883 } … … 863 895 uint64_t SQLiteIDBBackingStore::databasesSizeForOrigin() const 864 896 { 865 return databasesSizeForFolder(m_absoluteDatabaseDirectory); 897 String oldVersionOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory, "v0"); 898 String newVersionOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory, "v1"); 899 return databasesSizeForFolder(oldVersionOriginDirectory) + databasesSizeForFolder(newVersionOriginDirectory); 866 900 } 867 901 … … 1910 1944 1911 1945 ASSERT(!blobURLSet.isEmpty()); 1912 String databaseDirectory = fullDatabaseDirectory();1913 1946 for (auto& blobURL : blobURLSet) { 1914 1947 auto* sql = cachedStatement(SQL::BlobFilenameForBlobURL, "SELECT fileName FROM BlobFiles WHERE blobURL = ?;"_s); … … 1927 1960 1928 1961 String fileName = sql->getColumnText(0); 1929 blobFilePaths.append(FileSystem::pathByAppendingComponent( databaseDirectory, fileName));1962 blobFilePaths.append(FileSystem::pathByAppendingComponent(m_databaseDirectory, fileName)); 1930 1963 } 1931 1964 sessionID = m_identifier.sessionID(); … … 2606 2639 } 2607 2640 2608 String databaseDirectory = fullDatabaseDirectory();2609 2641 for (auto& file : blobFiles) { 2610 String fullPath = FileSystem::pathByAppendingComponent( databaseDirectory, file);2642 String fullPath = FileSystem::pathByAppendingComponent(m_databaseDirectory, file); 2611 2643 if (!FileSystem::deleteFile(fullPath)) 2612 2644 LOG_ERROR("Error deleting blob file %s", fullPath.utf8().data()); … … 2617 2649 2618 2650 SQLiteFileSystem::deleteDatabaseFile(dbFilename); 2619 SQLiteFileSystem::deleteEmptyDatabaseDirectory( fullDatabaseDirectory());2620 SQLiteFileSystem::deleteEmptyDatabaseDirectory(m_ absoluteDatabaseDirectory);2651 SQLiteFileSystem::deleteEmptyDatabaseDirectory(m_databaseDirectory); 2652 SQLiteFileSystem::deleteEmptyDatabaseDirectory(m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory)); 2621 2653 } 2622 2654 -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h
r242911 r243019 90 90 void unregisterCursor(SQLiteIDBCursor&); 91 91 92 String fullDatabaseDirectory() const;93 94 92 IDBBackingStoreTemporaryFileHandler& temporaryFileHandler() const { return m_temporaryFileHandler; } 95 93 … … 98 96 static String databaseNameFromEncodedFilename(const String&); 99 97 static uint64_t databasesSizeForFolder(const String& folder); 98 99 String databaseDirectory() const { return m_databaseDirectory; }; 100 static String fullDatabasePathForDirectory(const String&); 101 static String databaseNameFromFile(const String&); 100 102 101 103 private: 102 104 String filenameForDatabaseName() const; 103 105 String fullDatabasePath() const; 106 String fullDatabaseDirectoryWithUpgrade(); 104 107 105 108 uint64_t quotaForOrigin() const; … … 197 200 HashMap<IDBResourceIdentifier, SQLiteIDBCursor*> m_cursors; 198 201 199 String m_absoluteDatabaseDirectory; 202 String m_databaseRootDirectory; 203 String m_databaseDirectory; 200 204 201 205 RefPtr<JSC::VM> m_vm; -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp
r240437 r243019 88 88 void SQLiteIDBTransaction::moveBlobFilesIfNecessary() 89 89 { 90 String databaseDirectory = m_backingStore. fullDatabaseDirectory();90 String databaseDirectory = m_backingStore.databaseDirectory(); 91 91 for (auto& entry : m_blobTemporaryAndStoredFilenames) { 92 92 if (!FileSystem::hardLinkOrCopyFile(entry.first, FileSystem::pathByAppendingComponent(databaseDirectory, entry.second))) … … 104 104 return; 105 105 106 String databaseDirectory = m_backingStore. fullDatabaseDirectory();106 String databaseDirectory = m_backingStore.databaseDirectory(); 107 107 for (auto& entry : m_blobRemovedFilenames) { 108 108 String fullPath = FileSystem::pathByAppendingComponent(databaseDirectory, entry); -
trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp
r242251 r243019 34 34 #include "SQLiteDatabase.h" 35 35 #include "SQLiteStatement.h" 36 #include <pal/crypto/CryptoDigest.h> 36 37 #include <sqlite3.h> 37 38 #include <wtf/FileSystem.h> … … 113 114 return FileSystem::getFileModificationTime(fileName); 114 115 } 116 117 String SQLiteFileSystem::computeHashForFileName(const String& fileName) 118 { 119 auto cryptoDigest = PAL::CryptoDigest::create(PAL::CryptoDigest::Algorithm::SHA_256); 120 cryptoDigest->addBytes(fileName.utf8().data(), fileName.utf8().length()); 121 auto digest = cryptoDigest->computeHash(); 122 123 // Convert digest to hex. 124 char* start = 0; 125 unsigned digestLength = digest.size(); 126 CString result = CString::newUninitialized(digestLength * 2, start); 127 char* buffer = start; 128 for (size_t i = 0; i < digestLength; ++i) { 129 snprintf(buffer, 3, "%02X", digest.at(i)); 130 buffer += 2; 131 } 132 return String::fromUTF8(result); 133 } 115 134 116 135 } // namespace WebCore -
trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h
r242251 r243019 81 81 WEBCORE_EXPORT static bool deleteDatabaseFile(const String& fileName); 82 82 83 WEBCORE_EXPORT static String computeHashForFileName(const String& fileName); 84 83 85 #if PLATFORM(IOS_FAMILY) 84 86 // Truncates a database file. Used when MobileSafariSettings deletes a database file, -
trunk/Source/WebKit/ChangeLog
r243018 r243019 1 2019-03-15 Sihui Liu <sihui_liu@apple.com> 2 3 [ Mojave WK1 ] Layout Test storage/indexeddb/database-odd-names.html is failing 4 https://bugs.webkit.org/show_bug.cgi?id=190350 5 <rdar://problem/45089503> 6 7 Reviewed by Geoffrey Garen. 8 9 * NetworkProcess/NetworkProcess.cpp: 10 (WebKit::NetworkProcess::collectIndexedDatabaseOriginsForVersion): 11 (WebKit::NetworkProcess::indexedDatabaseOrigins): 12 * NetworkProcess/NetworkProcess.h: 13 * UIProcess/Network/NetworkProcessProxy.cpp: 14 (WebKit::NetworkProcessProxy::addSession): 15 (WebKit::NetworkProcessProxy::createSymLinkForFileUpgrade): For efficientcy and atomicity, we choose to use 16 symlink to create v0 folder. Because network process does not have the permission to create a symlink, we need 17 to do this in UI process. UI process would create v0 folder inside the IndexedDB directory if there isn't one. 18 Also if there is a v0 directory but it doesn't have content, it means it's not a correct symlink and we need to 19 delete it and create again. 20 21 * UIProcess/Network/NetworkProcessProxy.h: 22 * UIProcess/WebProcessPool.cpp: 23 (WebKit::WebProcessPool::ensureNetworkProcess): 24 25 2019-03-15 Sihui Liu <sihui_liu@apple.com> 26 27 [ Mojave WK1 ] Layout Test storage/indexeddb/database-odd-names.html is failing 28 https://bugs.webkit.org/show_bug.cgi?id=190350 29 <rdar://problem/45089503> 30 31 Reviewed by Geoffrey Garen. 32 33 * NetworkProcess/NetworkProcess.cpp: 34 (WebKit::NetworkProcess::collectIndexedDatabaseOriginsForVersion): 35 (WebKit::NetworkProcess::indexedDatabaseOrigins): 36 * NetworkProcess/NetworkProcess.h: 37 * UIProcess/Network/NetworkProcessProxy.cpp: 38 (WebKit::NetworkProcessProxy::addSession): 39 (WebKit::NetworkProcessProxy::createSymLinkForFileUpgrade): 40 * UIProcess/Network/NetworkProcessProxy.h: 41 * UIProcess/WebProcessPool.cpp: 42 (WebKit::WebProcessPool::ensureNetworkProcess): 43 1 44 2019-03-15 Per Arne Vollan <pvollan@apple.com> 2 45 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r242975 r243019 2122 2122 } 2123 2123 2124 void NetworkProcess::collectIndexedDatabaseOriginsForVersion(const String& path, HashSet<WebCore::SecurityOriginData>& securityOrigins) 2125 { 2126 if (path.isEmpty()) 2127 return; 2128 2129 for (auto& topOriginPath : FileSystem::listDirectory(path, "*")) { 2130 auto databaseIdentifier = FileSystem::pathGetFileName(topOriginPath); 2131 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) { 2132 securityOrigins.add(WTFMove(*securityOrigin)); 2133 2134 for (auto& originPath : FileSystem::listDirectory(topOriginPath, "*")) { 2135 databaseIdentifier = FileSystem::pathGetFileName(originPath); 2136 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 2137 securityOrigins.add(WTFMove(*securityOrigin)); 2138 } 2139 } 2140 } 2141 } 2142 2124 2143 HashSet<WebCore::SecurityOriginData> NetworkProcess::indexedDatabaseOrigins(const String& path) 2125 2144 { … … 2128 2147 2129 2148 HashSet<WebCore::SecurityOriginData> securityOrigins; 2130 for (auto& topOriginPath : FileSystem::listDirectory(path, "*")) { 2131 auto databaseIdentifier = FileSystem::pathGetFileName(topOriginPath); 2132 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 2133 securityOrigins.add(WTFMove(*securityOrigin)); 2134 2135 for (auto& originPath : FileSystem::listDirectory(topOriginPath, "*")) { 2136 databaseIdentifier = FileSystem::pathGetFileName(originPath); 2137 if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) 2138 securityOrigins.add(WTFMove(*securityOrigin)); 2139 } 2140 } 2149 collectIndexedDatabaseOriginsForVersion(FileSystem::pathByAppendingComponent(path, "v0"), securityOrigins); 2150 collectIndexedDatabaseOriginsForVersion(FileSystem::pathByAppendingComponent(path, "v1"), securityOrigins); 2141 2151 2142 2152 return securityOrigins; -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r242947 r243019 430 430 #if ENABLE(INDEXED_DATABASE) 431 431 void addIndexedDatabaseSession(PAL::SessionID, String&, SandboxExtension::Handle&); 432 void collectIndexedDatabaseOriginsForVersion(const String&, HashSet<WebCore::SecurityOriginData>&); 432 433 HashSet<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path); 433 434 Ref<WebCore::IDBServer::IDBServer> createIDBServer(PAL::SessionID); -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r242905 r243019 1064 1064 send(Messages::NetworkProcess::AddWebsiteDataStore { store->parameters() }, 0); 1065 1065 auto sessionID = store->sessionID(); 1066 if (!sessionID.isEphemeral()) 1066 if (!sessionID.isEphemeral()) { 1067 #if ENABLE(INDEXED_DATABASE) 1068 createSymLinkForFileUpgrade(store->resolvedIndexedDatabaseDirectory()); 1069 #endif 1067 1070 m_websiteDataStores.set(sessionID, WTFMove(store)); 1071 } 1068 1072 } 1069 1073 … … 1214 1218 } 1215 1219 1220 #if ENABLE(INDEXED_DATABASE) 1221 void NetworkProcessProxy::createSymLinkForFileUpgrade(const String& indexedDatabaseDirectory) 1222 { 1223 if (indexedDatabaseDirectory.isEmpty()) 1224 return; 1225 1226 String oldVersionDirectory = FileSystem::pathByAppendingComponent(indexedDatabaseDirectory, "v0"); 1227 FileSystem::deleteEmptyDirectory(oldVersionDirectory); 1228 if (!FileSystem::fileExists(oldVersionDirectory)) 1229 FileSystem::createSymbolicLink(indexedDatabaseDirectory, oldVersionDirectory); 1230 } 1231 #endif 1232 1216 1233 } // namespace WebKit 1217 1234 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r242905 r243019 177 177 void takeUploadAssertion(); 178 178 void clearUploadAssertion(); 179 180 #if ENABLE(INDEXED_DATABASE) 181 void createSymLinkForFileUpgrade(const String& indexedDatabaseDirectory); 182 #endif 179 183 180 184 private: -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r243009 r243019 552 552 553 553 SandboxExtension::createHandleForReadWriteDirectory(parameters.defaultDataStoreParameters.indexedDatabaseDirectory, parameters.defaultDataStoreParameters.indexedDatabaseDirectoryExtensionHandle); 554 m_networkProcess->createSymLinkForFileUpgrade(parameters.defaultDataStoreParameters.indexedDatabaseDirectory); 554 555 #endif 555 556 -
trunk/Tools/ChangeLog
r243012 r243019 1 2019-03-15 Sihui Liu <sihui_liu@apple.com> 2 3 [ Mojave WK1 ] Layout Test storage/indexeddb/database-odd-names.html is failing 4 https://bugs.webkit.org/show_bug.cgi?id=190350 5 <rdar://problem/45089503> 6 7 Reviewed by Geoffrey Garen. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKitCocoa/IDBIndexUpgradeToV2.mm: 11 (TEST): 12 * TestWebKitAPI/Tests/WebKitCocoa/IndexedDB.sqlite3: 13 * TestWebKitAPI/Tests/WebKitCocoa/IndexedDB.sqlite3-shm: 14 * TestWebKitAPI/Tests/WebKitCocoa/IndexedDB.sqlite3-wal: 15 * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBFileName-1.html: Added. 16 * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBFileName-2.html: Added. 17 * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBFileName.mm: Added. 18 (-[IndexedDBFileNameMessageHandler userContentController:didReceiveScriptMessage:]): 19 (runTest): 20 (createDirectories): 21 (TEST): 22 * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBTempFileSize.mm: 23 (TEST): 24 * TestWebKitAPI/Tests/WebKitCocoa/StoreBlobThenDelete.mm: 25 (TEST): 26 1 27 2019-03-15 Timothy Hatcher <timothy@apple.com> 2 28 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r242932 r243019 775 775 CA97B394219366600045DF6F /* IndexedDBUserDelete.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA97B3922193663B0045DF6F /* IndexedDBUserDelete.mm */; }; 776 776 CA97B3952193667A0045DF6F /* IndexedDBUserDelete.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CA97B393219366470045DF6F /* IndexedDBUserDelete.html */; }; 777 CAB0FF5222332407006CA5B0 /* IndexedDBFileName-1.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CAB0FF51223323F6006CA5B0 /* IndexedDBFileName-1.html */; }; 778 CAB0FF5322332407006CA5B0 /* IndexedDBFileName-2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CAB0FF50223323F6006CA5B0 /* IndexedDBFileName-2.html */; }; 779 CAB0FF5522332C57006CA5B0 /* IndexedDBFileName.mm in Sources */ = {isa = PBXBuildFile; fileRef = CAB0FF5422332C3A006CA5B0 /* IndexedDBFileName.mm */; }; 777 780 CD0BD0A61F79924D001AB2CF /* ContextMenuImgWithVideo.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD0BD0A51F799220001AB2CF /* ContextMenuImgWithVideo.mm */; }; 778 781 CD0BD0A81F79982D001AB2CF /* ContextMenuImgWithVideo.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */; }; … … 1144 1147 935786CC20F6A2700000CDFC /* IndexedDB.sqlite3-wal in Copy Resources */, 1145 1148 51A587851D2739E3004BA9AF /* IndexedDBDatabaseProcessKill-1.html in Copy Resources */, 1149 CAB0FF5222332407006CA5B0 /* IndexedDBFileName-1.html in Copy Resources */, 1150 CAB0FF5322332407006CA5B0 /* IndexedDBFileName-2.html in Copy Resources */, 1146 1151 51BCEE4E1C84F53B0042C82E /* IndexedDBMultiProcess-1.html in Copy Resources */, 1147 1152 51BCEE4F1C84F53B0042C82E /* IndexedDBMultiProcess-2.html in Copy Resources */, … … 2098 2103 CA97B3922193663B0045DF6F /* IndexedDBUserDelete.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBUserDelete.mm; sourceTree = "<group>"; }; 2099 2104 CA97B393219366470045DF6F /* IndexedDBUserDelete.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = IndexedDBUserDelete.html; sourceTree = "<group>"; }; 2105 CAB0FF50223323F6006CA5B0 /* IndexedDBFileName-2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBFileName-2.html"; sourceTree = "<group>"; }; 2106 CAB0FF51223323F6006CA5B0 /* IndexedDBFileName-1.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "IndexedDBFileName-1.html"; sourceTree = "<group>"; }; 2107 CAB0FF5422332C3A006CA5B0 /* IndexedDBFileName.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IndexedDBFileName.mm; sourceTree = "<group>"; }; 2100 2108 CD0BD0A51F799220001AB2CF /* ContextMenuImgWithVideo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenuImgWithVideo.mm; sourceTree = "<group>"; }; 2101 2109 CD0BD0A71F7997C2001AB2CF /* ContextMenuImgWithVideo.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = ContextMenuImgWithVideo.html; sourceTree = "<group>"; }; … … 2533 2541 5110FCEF1E01CBAA006F8D0B /* IDBIndexUpgradeToV2.mm */, 2534 2542 51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */, 2543 CAB0FF5422332C3A006CA5B0 /* IndexedDBFileName.mm */, 2535 2544 51BCEE491C84F4AF0042C82E /* IndexedDBMultiProcess.mm */, 2536 2545 51B1EE8D1C80F5880064FB98 /* IndexedDBPersistence.mm */, … … 2923 2932 934FA5C520F69FED0040DC1B /* IndexedDB.sqlite3-wal */, 2924 2933 51A587821D272EB5004BA9AF /* IndexedDBDatabaseProcessKill-1.html */, 2934 CAB0FF51223323F6006CA5B0 /* IndexedDBFileName-1.html */, 2935 CAB0FF50223323F6006CA5B0 /* IndexedDBFileName-2.html */, 2925 2936 51BCEE4C1C84F52C0042C82E /* IndexedDBMultiProcess-1.html */, 2926 2937 51BCEE4D1C84F52C0042C82E /* IndexedDBMultiProcess-2.html */, … … 4107 4118 5110FCFA1E01CDB8006F8D0B /* IDBIndexUpgradeToV2.mm in Sources */, 4108 4119 51A587861D273AA9004BA9AF /* IndexedDBDatabaseProcessKill.mm in Sources */, 4120 CAB0FF5522332C57006CA5B0 /* IndexedDBFileName.mm in Sources */, 4109 4121 7C83E0BE1D0A651300FEBCF3 /* IndexedDBMultiProcess.mm in Sources */, 4110 4122 7C83E0BF1D0A652200FEBCF3 /* IndexedDBPersistence.mm in Sources */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IDBIndexUpgradeToV2.mm
r242339 r243019 28 28 #import "PlatformUtilities.h" 29 29 #import "Test.h" 30 #import <WebCore/SQLiteFileSystem.h> 30 31 #import <WebKit/WKProcessPoolPrivate.h> 31 32 #import <WebKit/WKUserContentControllerPrivate.h> … … 64 65 NSURL *url2 = [[NSBundle mainBundle] URLForResource:@"IndexUpgrade" withExtension:@"blob" subdirectory:@"TestWebKitAPI.resources"]; 65 66 66 NSURL *targetURL = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/index-upgrade-test" stringByExpandingTildeInPath]]; 67 NSString *hash = WebCore::SQLiteFileSystem::computeHashForFileName("index-upgrade-test"); 68 NSString *originDirectory = @"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/v1/file__0/"; 69 NSString *databaseDirectory = [[originDirectory stringByAppendingString:hash] stringByExpandingTildeInPath]; 70 NSURL *targetURL = [NSURL fileURLWithPath:databaseDirectory]; 67 71 [[NSFileManager defaultManager] removeItemAtURL:targetURL error:nil]; 68 72 [[NSFileManager defaultManager] createDirectoryAtURL:targetURL withIntermediateDirectories:YES attributes:nil error:nil]; -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBTempFileSize.mm
r242339 r243019 28 28 #import "PlatformUtilities.h" 29 29 #import "Test.h" 30 #import <WebCore/SQLiteFileSystem.h> 30 31 #import <WebKit/WKProcessPoolPrivate.h> 31 32 #import <WebKit/WKUserContentControllerPrivate.h> … … 62 63 [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"]; 63 64 64 RetainPtr<NSURL> idbPath = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/CustomWebsiteData/IndexedDB/" stringByExpandingTildeInPath] isDirectory:YES]; 65 RetainPtr<NSURL> walFilePath = [NSURL fileURLWithPath:[@"~/Library/WebKit/TestWebKitAPI/CustomWebsiteData/IndexedDB/file__0/IndexedDBTempFileSize/IndexedDB.sqlite3-wal" stringByExpandingTildeInPath] isDirectory:NO]; 65 NSString *hash = WebCore::SQLiteFileSystem::computeHashForFileName("IndexedDBTempFileSize"); 66 NSString *databaseRootDirectory = [@"~/Library/WebKit/TestWebKitAPI/CustomWebsiteData/IndexedDB/" stringByExpandingTildeInPath]; 67 NSString *databaseDirectory = [[[databaseRootDirectory stringByAppendingPathComponent:@"v1"] stringByAppendingPathComponent:@"file__0"] stringByAppendingPathComponent:hash]; 68 RetainPtr<NSURL> idbPath = [NSURL fileURLWithPath:databaseRootDirectory isDirectory:YES]; 69 RetainPtr<NSURL> walFilePath = [NSURL fileURLWithPath:[databaseDirectory stringByAppendingPathComponent:@"IndexedDB.sqlite3-wal"] isDirectory:NO]; 66 70 67 71 auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]); -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/StoreBlobThenDelete.mm
r242339 r243019 28 28 #import "PlatformUtilities.h" 29 29 #import "Test.h" 30 #import <WebCore/SQLiteFileSystem.h> 30 31 #import <WebKit/WebKit.h> 31 32 #import <WebKit/WKProcessPoolPrivate.h> … … 66 67 EXPECT_WK_STREQ(@"Success", (NSString *)[lastScriptMessage body]); 67 68 68 NSString *blobFilePath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/StoreBlobToBeDeleted/1.blob" stringByExpandingTildeInPath]; 69 NSString *databaseFilePath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/StoreBlobToBeDeleted/IndexedDB.sqlite3" stringByExpandingTildeInPath]; 69 NSString *hash = WebCore::SQLiteFileSystem::computeHashForFileName("StoreBlobToBeDeleted"); 70 NSString *originDirectory = @"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/v1/file__0/"; 71 NSString *databaseDirectory = [[originDirectory stringByAppendingString:hash] stringByExpandingTildeInPath]; 72 NSString *blobFilePath = [databaseDirectory stringByAppendingPathComponent:@"1.blob"]; 73 NSString *databaseFilePath = [databaseDirectory stringByAppendingPathComponent:@"IndexedDB.sqlite3"]; 70 74 71 75 // The database file and blob file should definitely be there right now. … … 78 82 // 2 - Move -wal and -shm files into that directory 79 83 // 3 - Make sure the entire directory is deleted 80 NSString *fakeDatabasePath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/FakeDatabasePath" stringByExpandingTildeInPath]; 81 NSString *fakeShmPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/FakeDatabasePath/IndexedDB.sqlite3-wal" stringByExpandingTildeInPath]; 82 NSString *fakeWalPath = [@"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/FakeDatabasePath/IndexedDB.sqlite3-shm" stringByExpandingTildeInPath]; 83 [[NSFileManager defaultManager] createDirectoryAtPath:fakeDatabasePath withIntermediateDirectories:NO attributes:nil error:nil]; 84 NSString *fakeHash = WebCore::SQLiteFileSystem::computeHashForFileName("FakeDatabasePath"); 85 NSString *fakeDatabaseDirectory = [[originDirectory stringByAppendingString:fakeHash] stringByExpandingTildeInPath]; 86 NSString *fakeShmPath = [fakeDatabaseDirectory stringByAppendingPathComponent:@"IndexedDB.sqlite3-wal"]; 87 NSString *fakeWalPath = [fakeDatabaseDirectory stringByAppendingPathComponent:@"IndexedDB.sqlite3-shm"]; 88 [[NSFileManager defaultManager] createDirectoryAtPath:fakeDatabaseDirectory withIntermediateDirectories:NO attributes:nil error:nil]; 84 89 [[NSFileManager defaultManager] copyItemAtPath:databaseFilePath toPath:fakeShmPath error:nil]; 85 90 [[NSFileManager defaultManager] copyItemAtPath:databaseFilePath toPath:fakeWalPath error:nil]; 86 91 87 92 // Make some other .blob files in the database directory to later validate that only appropriate files are deleted. 88 NSString *otherBlob1 = [ @"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/StoreBlobToBeDeleted/7182.blob" stringByExpandingTildeInPath];89 NSString *otherBlob2 = [ @"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/StoreBlobToBeDeleted/1a.blob" stringByExpandingTildeInPath];90 NSString *otherBlob3 = [ @"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/StoreBlobToBeDeleted/a1.blob" stringByExpandingTildeInPath];91 NSString *otherBlob4 = [ @"~/Library/WebKit/TestWebKitAPI/WebsiteData/IndexedDB/file__0/StoreBlobToBeDeleted/.blob" stringByExpandingTildeInPath];93 NSString *otherBlob1 = [databaseDirectory stringByAppendingPathComponent:@"7182.blob"]; 94 NSString *otherBlob2 = [databaseDirectory stringByAppendingPathComponent:@"1a.blob"]; 95 NSString *otherBlob3 = [databaseDirectory stringByAppendingPathComponent:@"a1.blob"]; 96 NSString *otherBlob4 = [databaseDirectory stringByAppendingPathComponent:@".blob"]; 92 97 [[NSFileManager defaultManager] copyItemAtPath:blobFilePath toPath:otherBlob1 error:nil]; 93 98 [[NSFileManager defaultManager] copyItemAtPath:blobFilePath toPath:otherBlob2 error:nil]; … … 111 116 EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fakeShmPath]); 112 117 EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fakeWalPath]); 113 EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fakeDatabase Path]);118 EXPECT_FALSE([[NSFileManager defaultManager] fileExistsAtPath:fakeDatabaseDirectory]); 114 119 115 120 // Now delete them so we're not leaving files around.
Note: See TracChangeset
for help on using the changeset viewer.