Skip to content
Snippets Groups Projects
Commit edb401b2 authored by benjamin's avatar benjamin
Browse files

undid a db hack

parent 8a62c812
No related branches found
No related tags found
1 merge request!60Revert "Fail a test to be sure it works"
...@@ -93,6 +93,27 @@ func newWASMModel(databaseName string, encryption cryptoChannel.Cipher, ...@@ -93,6 +93,27 @@ func newWASMModel(databaseName string, encryption cryptoChannel.Cipher,
return nil, err return nil, err
} }
// FIXME: The below is a hack that for some reason prevents moving on with
// uninitialized database despite the previous call to Await.
// It would be idea to find a different solution.
// Close and open again to ensure the state is finalized
err = db.Close()
if err != nil {
return nil, err
}
openRequest, err = idb.Global().Open(ctx, databaseName, currentVersion,
func(db *idb.Database, oldVersion, newVersion uint) error {
return nil
})
if err != nil {
return nil, err
}
// Wait for database open to finish
db, err = openRequest.Await(ctx)
if err != nil {
return nil, err
}
// Save the encryption status to storage // Save the encryption status to storage
encryptionStatus := encryption != nil encryptionStatus := encryption != nil
loadedEncryptionStatus, err := storage.StoreIndexedDbEncryptionStatus( loadedEncryptionStatus, err := storage.StoreIndexedDbEncryptionStatus(
...@@ -111,7 +132,7 @@ func newWASMModel(databaseName string, encryption cryptoChannel.Cipher, ...@@ -111,7 +132,7 @@ func newWASMModel(databaseName string, encryption cryptoChannel.Cipher,
// Attempt to ensure the database has been properly initialized // Attempt to ensure the database has been properly initialized
wrapper := &wasmModel{db: db, receivedMessageCB: cb, cipher: encryption} wrapper := &wasmModel{db: db, receivedMessageCB: cb, cipher: encryption}
return wrapper, wrapper.hackTestDb() return wrapper, nil
} }
// v1Upgrade performs the v0 -> v1 database upgrade. // v1Upgrade performs the v0 -> v1 database upgrade.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment