diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp @@ -3333,10 +3333,6 @@ throw std::runtime_error("Backup file or encryption key corrupted."); } -// We don't want to run `PRAGMA key = ...;` -// on main web database. The context is here: -// https://linear.app/comm/issue/ENG-6398/issues-with-sqlcipher-on-web -#ifdef EMSCRIPTEN std::string plaintextBackupPath = mainCompactionPath + "_plaintext"; if (file_exists(plaintextBackupPath)) { attempt_delete_file( @@ -3345,6 +3341,7 @@ "attempt."); } + sqlite3_open(mainCompactionPath.c_str(), &backupDB); std::string plaintextMigrationDBQuery = "PRAGMA key = \"x'" + mainCompactionEncryptionKey + "'\";" @@ -3353,34 +3350,10 @@ "' AS plaintext KEY '';" "SELECT sqlcipher_export('plaintext');" "DETACH DATABASE plaintext;"; - - sqlite3_open(mainCompactionPath.c_str(), &backupDB); - - char *plaintextMigrationErr; - sqlite3_exec( - backupDB, - plaintextMigrationDBQuery.c_str(), - nullptr, - nullptr, - &plaintextMigrationErr); + executeQuery(backupDB, plaintextMigrationDBQuery); sqlite3_close(backupDB); - if (plaintextMigrationErr) { - std::stringstream error_message; - error_message << "Failed to migrate backup SQLCipher file to plaintext " - "SQLite file. Details" - << plaintextMigrationErr << std::endl; - std::string error_message_str = error_message.str(); - sqlite3_free(plaintextMigrationErr); - - throw std::runtime_error(error_message_str); - } - sqlite3_open(plaintextBackupPath.c_str(), &backupDB); -#else - sqlite3_open(mainCompactionPath.c_str(), &backupDB); - set_encryption_key(backupDB, mainCompactionEncryptionKey); -#endif int version = this->getSyncedDatabaseVersion(backupDB).value_or(-1); if (version > std::stoi(maxVersion)) { @@ -3417,11 +3390,9 @@ throw std::runtime_error(error_message.str()); } -#ifdef EMSCRIPTEN attempt_delete_file( plaintextBackupPath, "Failed to delete plaintext compaction file after successful restore."); -#endif attempt_delete_file( mainCompactionPath, diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@<O00001 literal 0 Hc$@<O00001