From b8b6370fec14354aac2e2b74476149d7b85c9c5c Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 18 Dec 2019 08:46:54 +0900 Subject: [PATCH] Prevent duplicate installation - 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 --- parser/component/data/component.info | 2 +- parser/component/src/component_plugin_parser_db.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/parser/component/data/component.info b/parser/component/data/component.info index 836722f..9effa23 100644 --- a/parser/component/data/component.info +++ b/parser/component/data/component.info @@ -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" diff --git a/parser/component/src/component_plugin_parser_db.c b/parser/component/src/component_plugin_parser_db.c index 3851685..b8cc8e4 100644 --- a/parser/component/src/component_plugin_parser_db.c +++ b/parser/component/src/component_plugin_parser_db.c @@ -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) " -- 2.7.4