Skip to content

Commit

Permalink
Merge pull request #218 from OP-Engineering/oscar/try-realpath
Browse files Browse the repository at this point in the history
Try to call realpath to resolve the correct location of the db
  • Loading branch information
ospfranco authored Dec 30, 2024
2 parents e56ca63 + acfcb50 commit cdd3a65
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ std::string opsqlite_get_db_path(std::string const &db_name,
}

mkdir(location);
return location + "/" + db_name;
char resolved_path[PATH_MAX];
realpath((location + "/" + db_name).c_str(), resolved_path);
return std::string(resolved_path);
}

#ifdef OP_SQLITE_USE_SQLCIPHER
sqlite3 *opsqlite_open(std::string const &name, std::string const &path,
std::string const &crsqlite_path,
std::string const &sqlite_vec_path,
std::string const &encryption_key) {
std::string const &crsqlite_path,
std::string const &sqlite_vec_path,
std::string const &encryption_key) {
#else
sqlite3 *opsqlite_open(std::string const &name, std::string const &path,
[[maybe_unused]] std::string const &crsqlite_path,
Expand All @@ -95,7 +97,7 @@ sqlite3 *opsqlite_open(std::string const &name, std::string const &path,
}

#ifdef OP_SQLITE_USE_SQLCIPHER
if(!encryption_key.empty()) {
if (!encryption_key.empty()) {
opsqlite_execute(db, "PRAGMA key = '" + encryption_key + "'", nullptr);
}
#endif
Expand Down

0 comments on commit cdd3a65

Please sign in to comment.