Prevent duplicate installation 63/220363/3
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 17 Dec 2019 23:46:54 +0000 (08:46 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 18 Dec 2019 00:50:47 +0000 (09:50 +0900)
- Adds vitalness attribute on component parser plugin
- Changes queries to "INSERT" from "INSERT OR REPLACE"
- Adds a missing command to enable "foreign_keys" option

Change-Id: I7543ce3e69677be6e09205ac3c60b80bdfb4158a
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
parser/component/data/component.info
parser/component/src/component_plugin_parser_db.c

index 836722f..9effa23 100644 (file)
@@ -1 +1 @@
-type="tag";name="component-based-application";path="/etc/package-manager/parserlib/libcomponent-based-application.so"
+type="tag";name="component-based-application";path="/etc/package-manager/parserlib/libcomponent-based-application.so";vitalness="true"
index 3851685..b8cc8e4 100644 (file)
@@ -148,8 +148,7 @@ static sqlite3 *__open_db(const char *path)
        ret = sqlite3_open_v2(path, &db, SQLITE_OPEN_READWRITE, NULL);
        if (ret != SQLITE_OK) {
                LOGE("sqlite3_open_v2() is failed. error(%d)", ret);
-               if (db)
-                       sqlite3_close_v2(db);
+               sqlite3_close_v2(db);
                return NULL;
        }
 
@@ -161,6 +160,14 @@ static sqlite3 *__open_db(const char *path)
                return NULL;
        }
 
+       ret = sqlite3_exec(db, "PRAGMA foreign_keys=ON", NULL, NULL, NULL);
+       if (ret != SQLITE_OK) {
+               LOGE("Failed to enable foreign key support. error(%s)",
+                               sqlite3_errmsg(db));
+               sqlite3_close_v2(db);
+               return NULL;
+       }
+
        return db;
 }
 
@@ -524,7 +531,7 @@ static int __insert_component_localized_info(component_t *component,
                GList *locales)
 {
        static const char query[] =
-               "INSERT OR REPLACE INTO component_localized_info "
+               "INSERT INTO component_localized_info "
                "(component_id, component_locale, component_label, "
                "component_icon) VALUES (?, ?, ?, ?)";
        sqlite3_stmt *stmt = NULL;
@@ -577,7 +584,7 @@ static int __insert_component_localized_info(component_t *component,
 int component_plugin_parser_db_insert(component_t *component)
 {
        static const char query[] =
-               "INSERT OR REPLACE INTO component_info "
+               "INSERT INTO component_info "
                "(package, app_id, component_id, component_type, "
                "component_launch_mode, component_main, "
                "component_icon_display, component_taskmanage) "