mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibWeb: Store IndexedDB Databases mappings properly
This commit is contained in:
parent
1656d8fe07
commit
932fb2024e
Notes:
github-actions[bot]
2024-11-26 13:51:43 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/932fb2024ee Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2236 Reviewed-by: https://github.com/gmta ✅
2 changed files with 12 additions and 4 deletions
|
@ -40,8 +40,11 @@ WebIDL::ExceptionOr<GC::Ref<IDBDatabase>> open_a_database_connection(JS::Realm&
|
|||
}));
|
||||
|
||||
// 4. Let db be the database named name in storageKey, or null otherwise.
|
||||
auto maybe_db = Database::for_key_and_name(storage_key, name);
|
||||
GC::Ptr<Database> db;
|
||||
auto maybe_db = Database::for_key_and_name(storage_key, name);
|
||||
if (maybe_db.has_value()) {
|
||||
db = maybe_db.value();
|
||||
}
|
||||
|
||||
// 5. If version is undefined, let version be 1 if db is null, or db’s version otherwise.
|
||||
auto version = maybe_version.value_or(maybe_db.has_value() ? maybe_db.value()->version() : 1);
|
||||
|
|
|
@ -52,9 +52,12 @@ ErrorOr<GC::Root<Database>> Database::create_for_key_and_name(JS::Realm& realm,
|
|||
return HashMap<String, GC::Root<Database>>();
|
||||
}));
|
||||
|
||||
return database_mapping.try_ensure(name, [&] {
|
||||
return Database::create(realm, name);
|
||||
});
|
||||
auto value = Database::create(realm, name);
|
||||
|
||||
database_mapping.set(name, value);
|
||||
m_databases.set(key, database_mapping);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
ErrorOr<void> Database::delete_for_key_and_name(StorageAPI::StorageKey& key, String& name)
|
||||
|
@ -73,6 +76,8 @@ ErrorOr<void> Database::delete_for_key_and_name(StorageAPI::StorageKey& key, Str
|
|||
if (!did_remove)
|
||||
return {};
|
||||
|
||||
m_databases.set(key, database_mapping);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue