Skip to content

Commit

Permalink
fix: replace sqlite3_open16 (#1751)
Browse files Browse the repository at this point in the history
Co-authored-by: vansangpfiev <[email protected]>
  • Loading branch information
vansangpfiev and sangjanai authored Nov 29, 2024
1 parent 6457a10 commit 104ed76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 1 addition & 6 deletions engine/migrations/migration_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@ cpp::result<bool, std::string> MigrationHelper::BackupDatabase(
try {
SQLite::Database src_db(src_db_path, SQLite::OPEN_READONLY);
sqlite3* backup_db;
#if defined(_WIN32)
if (sqlite3_open16(backup_db_path.c_str(), &backup_db) != SQLITE_OK) {
throw std::runtime_error("Failed to open backup database");
}
#else

if (sqlite3_open(backup_db_path.c_str(), &backup_db) != SQLITE_OK) {
throw std::runtime_error("Failed to open backup database");
}
#endif

sqlite3_backup* backup =
sqlite3_backup_init(backup_db, "main", src_db.getHandle(), "main");
Expand Down
9 changes: 8 additions & 1 deletion engine/migrations/migration_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "schema_version.h"
#include "utils/file_manager_utils.h"
#include "utils/scope_exit.h"
#include "utils/widechar_conv.h"

namespace cortex::migr {

Expand Down Expand Up @@ -40,7 +41,13 @@ cpp::result<bool, std::string> MigrationManager::Migrate() {
if (std::filesystem::exists(fmu::GetCortexDataPath() / kCortexDb)) {
auto src_db_path = (fmu::GetCortexDataPath() / kCortexDb);
auto backup_db_path = (fmu::GetCortexDataPath() / kCortexDbBackup);
if (auto res = mgr_helper_.BackupDatabase(src_db_path, backup_db_path.string());
#if defined(_WIN32)
if (auto res = mgr_helper_.BackupDatabase(
src_db_path, cortex::wc::WstringToUtf8(backup_db_path.wstring()));
#else
if (auto res =
mgr_helper_.BackupDatabase(src_db_path, backup_db_path.string());
#endif
res.has_error()) {
CTL_INF("Error: backup database failed!");
return res;
Expand Down

0 comments on commit 104ed76

Please sign in to comment.