* limitations under the License.
*/
-#include <algorithm>
-
-#include "db_manager.h"
#include "log.h"
-#include "tac_common.h"
+#include "db_manager.h"
+
+#include <algorithm>
#ifdef LOG_TAG
#undef LOG_TAG
int ret = sqlite3_open(path.c_str(), &sqlite);
if (ret != SQLITE_OK) {
_INFO("DB file is corrupted, start to recover corrupted db");
- if (restoreTACDB() != TAC_ERROR_NONE) {
- _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
- return NULL;
- }
- return dbCreate(path, query);
+ return sqlite;
}
ret = sqlite3_exec(sqlite, "PRAGMA journal_mode = PERSIST", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
ret = sqlite3_exec(sqlite, "PRAGMA integrity_check", dbIntegrityCheckCb, &is_db_corrupted, NULL);
if (ret == SQLITE_CORRUPT || is_db_corrupted) {
_INFO("DB file is corrupted, start to recover corrupted db");
- if (restoreTACDB() != TAC_ERROR_NONE) {
- _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
- sqlite3_close(sqlite);
- sqlite = NULL;
- return sqlite;
- }
- return dbCreate(path, query);
+ sqlite3_close(sqlite);
+ sqlite = NULL;
+ return sqlite;
}
return sqlite;
}
int ret = sqlite3_open(path.c_str(), &sqlite);
if (ret != SQLITE_OK) {
_INFO("DB file is corrupted, start to recover corrupted db");
- if (restoreTACDB() != TAC_ERROR_NONE) {
- _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
- return NULL;
- }
- return dbOpen(path);
+ return sqlite;
}
ret = sqlite3_exec(sqlite, "PRAGMA integrity_check", dbIntegrityCheckCb, &is_db_corrupted, NULL);
if (ret == SQLITE_CORRUPT || is_db_corrupted) {
_INFO("DB file is corrupted, start to recover corrupted db");
- if (restoreTACDB() != TAC_ERROR_NONE) {
- _ERR("Sqlite error : [%d, %s]", ret, path.c_str());
- sqlite3_close(sqlite);
- sqlite = NULL;
- return sqlite;
- }
- return dbOpen(path);
+ sqlite3_close(sqlite);
+ sqlite = NULL;
+ return sqlite;
}
return sqlite;
}