Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 104ed76

Browse files
fix: replace sqlite3_open16 (#1751)
Co-authored-by: vansangpfiev <sang@jan.ai>
1 parent 6457a10 commit 104ed76

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

engine/migrations/migration_helper.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,10 @@ cpp::result<bool, std::string> MigrationHelper::BackupDatabase(
77
try {
88
SQLite::Database src_db(src_db_path, SQLite::OPEN_READONLY);
99
sqlite3* backup_db;
10-
#if defined(_WIN32)
11-
if (sqlite3_open16(backup_db_path.c_str(), &backup_db) != SQLITE_OK) {
12-
throw std::runtime_error("Failed to open backup database");
13-
}
14-
#else
10+
1511
if (sqlite3_open(backup_db_path.c_str(), &backup_db) != SQLITE_OK) {
1612
throw std::runtime_error("Failed to open backup database");
1713
}
18-
#endif
1914

2015
sqlite3_backup* backup =
2116
sqlite3_backup_init(backup_db, "main", src_db.getHandle(), "main");

engine/migrations/migration_manager.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "schema_version.h"
55
#include "utils/file_manager_utils.h"
66
#include "utils/scope_exit.h"
7+
#include "utils/widechar_conv.h"
78

89
namespace cortex::migr {
910

@@ -40,7 +41,13 @@ cpp::result<bool, std::string> MigrationManager::Migrate() {
4041
if (std::filesystem::exists(fmu::GetCortexDataPath() / kCortexDb)) {
4142
auto src_db_path = (fmu::GetCortexDataPath() / kCortexDb);
4243
auto backup_db_path = (fmu::GetCortexDataPath() / kCortexDbBackup);
43-
if (auto res = mgr_helper_.BackupDatabase(src_db_path, backup_db_path.string());
44+
#if defined(_WIN32)
45+
if (auto res = mgr_helper_.BackupDatabase(
46+
src_db_path, cortex::wc::WstringToUtf8(backup_db_path.wstring()));
47+
#else
48+
if (auto res =
49+
mgr_helper_.BackupDatabase(src_db_path, backup_db_path.string());
50+
#endif
4451
res.has_error()) {
4552
CTL_INF("Error: backup database failed!");
4653
return res;

0 commit comments

Comments
 (0)