Skip to content

Commit cdd3a65

Browse files
authored
Merge pull request #218 from OP-Engineering/oscar/try-realpath
Try to call realpath to resolve the correct location of the db
2 parents e56ca63 + acfcb50 commit cdd3a65

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

cpp/bridge.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ std::string opsqlite_get_db_path(std::string const &db_name,
6868
}
6969

7070
mkdir(location);
71-
return location + "/" + db_name;
71+
char resolved_path[PATH_MAX];
72+
realpath((location + "/" + db_name).c_str(), resolved_path);
73+
return std::string(resolved_path);
7274
}
7375

7476
#ifdef OP_SQLITE_USE_SQLCIPHER
7577
sqlite3 *opsqlite_open(std::string const &name, std::string const &path,
76-
std::string const &crsqlite_path,
77-
std::string const &sqlite_vec_path,
78-
std::string const &encryption_key) {
78+
std::string const &crsqlite_path,
79+
std::string const &sqlite_vec_path,
80+
std::string const &encryption_key) {
7981
#else
8082
sqlite3 *opsqlite_open(std::string const &name, std::string const &path,
8183
[[maybe_unused]] std::string const &crsqlite_path,
@@ -95,7 +97,7 @@ sqlite3 *opsqlite_open(std::string const &name, std::string const &path,
9597
}
9698

9799
#ifdef OP_SQLITE_USE_SQLCIPHER
98-
if(!encryption_key.empty()) {
100+
if (!encryption_key.empty()) {
99101
opsqlite_execute(db, "PRAGMA key = '" + encryption_key + "'", nullptr);
100102
}
101103
#endif

0 commit comments

Comments
 (0)