static bool is_db_corrupted = false;
+static const char* _db_path = DB_PATH;
+
+int shortcut_set_db_path(const char *db_path)
+{
+ _db_path = db_path;
+ return 0;
+}
+
/* LCOV_EXCL_START */
static int __check_integrity_cb(void *pid, int argc, char **argv, char **notUsed)
{
SHORTCUT_INFO("DB is corrupted, start to recover corrupted db");
if (db)
sqlite3_close(db);
- unlink(DB_PATH);
+ unlink(_db_path);
- sql_ret = sqlite3_open_v2(DB_PATH, &db,
+ sql_ret = sqlite3_open_v2(_db_path, &db,
SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE,
NULL);
if (sql_ret != SQLITE_OK) {
SHORTCUT_ERR("Failed to open db[%d]", sql_ret);
- unlink(DB_PATH);
+ unlink(_db_path);
ret = SHORTCUT_ERROR_IO_ERROR;
goto out;
}
sqlite3 *db = NULL;
char *errmsg = NULL;
- sql_ret = sqlite3_open_v2(DB_PATH, &db,
+ sql_ret = sqlite3_open_v2(_db_path, &db,
SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, NULL);
if (sql_ret != SQLITE_OK) {
SHORTCUT_ERR("Failed to open db[%d]", sql_ret);
static sqlite3 *_open_db(void)
{
int ret;
- const char *dbfile = DB_PATH;
+ const char *dbfile = _db_path;
sqlite3 *db = NULL;
ret = db_util_open(dbfile, &db, 0);