Support for TLC(Tizen Library cache) (#260)
[platform/core/dotnet/launcher.git] / NativeLauncher / util / db_manager.cc
index d42c066..0e05814 100644 (file)
  * 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
@@ -46,11 +45,7 @@ sqlite3* dbCreate(std::string path, std::string query)
        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) {
@@ -69,13 +64,9 @@ sqlite3* dbCreate(std::string path, std::string query)
        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;
 }
@@ -87,22 +78,14 @@ sqlite3* dbOpen(std::string path)
        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;
 }