Reduce DB connection when noti 10/206010/2 submit/tizen/20190515.071609
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 13 May 2019 07:51:49 +0000 (16:51 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 15 May 2019 02:47:18 +0000 (11:47 +0900)
Change-Id: I69d7aa3db5656cce399d37eaa0be80c0abe70b89
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
lib/media-util-noti-internal.c
src/common/include/media-common-db-svc.h
src/common/media-common-db-svc.c
src/scanner-v2/media-scanner-extract-v2.c
src/scanner-v2/media-scanner-scan-v2.c
src/scanner/media-scanner-scan.c

index f1901e2..f6e5539 100755 (executable)
@@ -65,7 +65,7 @@ int media_db_update_send_internal(int pid, /* mandatory */
        if (!bus) {
                MSAPI_DBG("Failed to get gdbus connection: %s", error->message);
                g_error_free(error);
-               return MS_MEDIA_ERR_INTERNAL;
+               return MS_MEDIA_ERR_SEND_NOTI_FAIL;
        }
 
        if (item == MS_MEDIA_ITEM_FILE) {
@@ -75,7 +75,7 @@ int media_db_update_send_internal(int pid, /* mandatory */
                        message = g_variant_new("(iiissis)", item, pid, update_type, path, uuid, media_type, mime_type);
                } else {
                        MSAPI_DBG_ERR("uuid or mime_type is NULL");
-                       return MS_MEDIA_ERR_INVALID_PARAMETER;
+                       return MS_MEDIA_ERR_SEND_NOTI_FAIL;
                }
        } else if (item == MS_MEDIA_ITEM_DIRECTORY) {
                MSAPI_DBG("DIRECTORY CHANGED");
@@ -90,7 +90,7 @@ int media_db_update_send_internal(int pid, /* mandatory */
 
        if (message == NULL) {
                MSAPI_DBG_ERR("g_dbus_message_new_signal failed");
-               return MS_MEDIA_ERR_INTERNAL;
+               return MS_MEDIA_ERR_SEND_NOTI_FAIL;
        }
 
        /* Send the signal */
@@ -109,13 +109,12 @@ int media_db_update_send_internal(int pid, /* mandatory */
                        g_object_unref(bus);
                        g_error_free(error);
                }
-               return MS_MEDIA_ERR_INTERNAL;
+               return MS_MEDIA_ERR_SEND_NOTI_FAIL;
        }
 
 
        g_object_unref(bus);
 
-       /* Return TRUE to tell the event loop we want to be called again */
        return MS_MEDIA_ERR_NONE;
 }
 
index bdab487..073377f 100755 (executable)
@@ -58,7 +58,7 @@ typedef int (*INSERT_ITEM_END)(uid_t);
 typedef int (*SET_ITEM_VALIDITY_BEGIN)(int);
 typedef int (*SET_ITEM_VALIDITY_END)(uid_t);
 
-typedef int (*SEND_DIR_UPDATE_NOTI)(sqlite3 *, const char *, const char *, const char *, int, int);
+typedef int (*SEND_DIR_UPDATE_NOTI)(const char *, const char *, int, int);
 typedef int (*INSERT_ITEM)(sqlite3 *, const char *, const char *, int, uid_t);
 typedef int (*SET_ITEM_VALIDITY)(const char *, const char *, int, int, uid_t);
 typedef int (*DELETE_ITEM)(sqlite3 *, const char *, const char *, uid_t);
@@ -107,7 +107,7 @@ int ms_validity_change_all_items(sqlite3 *handle, const char *storage_id, bool v
 bool ms_delete_invalid_items(sqlite3 *handle, const char *storage_id, uid_t uid);
 int ms_set_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *path, int validity, int recursive, uid_t uid);
 int ms_delete_invalid_items_in_folder(sqlite3 *handle, const char *storage_id, const char *path, bool is_recursive, uid_t uid);
-int ms_send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *path, const char *folder_id, ms_noti_type_e noti_type, int pid);
+int ms_send_dir_update_noti(const char *path, const char *folder_id, ms_noti_type_e noti_type, int pid);
 int ms_update_folder_time(sqlite3 *handle, const char *storage_id, char *folder_path, uid_t uid);
 int ms_get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid);
 int ms_set_storage_scan_status(sqlite3 *handle, char *storage_id, media_scan_status_e scan_status, uid_t uid);
index 5cbaaae..6c2a221 100755 (executable)
@@ -619,13 +619,13 @@ int ms_delete_invalid_items_in_folder(sqlite3 *handle, const char* storage_id, c
        return ret;
 }
 
-int ms_send_dir_update_noti(sqlite3 *handle, const char* storage_id, const char*path, const char*folder_id, ms_noti_type_e noti_type, int pid)
+int ms_send_dir_update_noti(const char*path, const char*folder_id, ms_noti_type_e noti_type, int pid)
 {
        int lib_index;
        int ret = MS_MEDIA_ERR_NONE;
 
        for (lib_index = 0; lib_index < lib_num; lib_index++) {
-               ret = ((SEND_DIR_UPDATE_NOTI)func_array[lib_index][eSEND_DIR_UPDATE_NOTI])(handle, storage_id, path, folder_id, (int)noti_type, pid); /*dlopen*/
+               ret = ((SEND_DIR_UPDATE_NOTI)func_array[lib_index][eSEND_DIR_UPDATE_NOTI])(path, folder_id, (int)noti_type, pid); /*dlopen*/
                MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Error : %s", g_array_index(so_array, char*, lib_index));
        }
 
index a39fbee..e5ab30f 100755 (executable)
@@ -293,7 +293,7 @@ NEXT:
                                char *folder_uuid = NULL;
                                ms_get_folder_id(handle, storage_id, extract_data->msg, &folder_uuid);
                                MS_DBG_WARN("storage_id = [%s], dir Path = [%s], folder_uuid = [%s], noti_type = [%d]", storage_id, update_path, folder_uuid, noti_type);
-                               ms_send_dir_update_noti(handle, storage_id, update_path, folder_uuid, noti_type, extract_data->pid);
+                               ms_send_dir_update_noti(update_path, folder_uuid, noti_type, extract_data->pid);
                        }
                        extract_data->msg_type = MS_MSG_EXTRACTOR_COMPLETE;
                        msc_send_result(ret, extract_data);
@@ -449,7 +449,7 @@ gboolean msc_storage_extract_thread(void *data)
                        __msc_set_storage_extract_status(MS_STORAGE_SCAN_COMPLETE);
 
                        /* send notification */
-                       ms_send_dir_update_noti(handle, extract_data->storage_id, update_path, NULL, MS_ITEM_UPDATE, extract_data->pid);
+                       ms_send_dir_update_noti(update_path, NULL, MS_ITEM_UPDATE, extract_data->pid);
                        /* set vconf key db extract status */
                        __msc_extract_set_db_status(MS_DB_UPDATED);
                        goto STOP_DISC;
index 9e05b40..a4adc45 100755 (executable)
@@ -1294,7 +1294,7 @@ gboolean msc_directory_scan_thread(void *data)
                }
 
                /*if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
-                       ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
+                       ms_send_dir_update_noti(scan_data->msg, folder_uuid, noti_type, scan_data->pid);
                }*/
 
 SCAN_DONE:
@@ -1307,7 +1307,7 @@ SCAN_DONE:
                                }
                        }
                        if (noti_type == MS_ITEM_DELETE) {
-                               ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
+                               ms_send_dir_update_noti(scan_data->msg, folder_uuid, noti_type, scan_data->pid);
                        }
                        msc_insert_exactor_request(scan_data->msg_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid, noti_type);
                }
@@ -1471,7 +1471,7 @@ gboolean msc_storage_scan_thread(void *data)
                }
 
                /* send notification */
-               /*ms_send_dir_update_noti(handle, scan_data->storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);*/
+               /*ms_send_dir_update_noti(update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);*/
 
                if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
                        ms_set_storage_scan_status(handle, scan_data->storage_id, MEDIA_SCAN_STOP, uid);
index e57e629..a1b2d23 100755 (executable)
@@ -322,7 +322,7 @@ gboolean msc_directory_scan_thread(void *data)
                        if (noti_type != MS_ITEM_DELETE)
                                ms_get_folder_id(handle, storage_id, scan_data->msg, &folder_uuid);
 
-                       ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
+                       ms_send_dir_update_noti(scan_data->msg, folder_uuid, noti_type, scan_data->pid);
                }
 
                if (power_off) {
@@ -435,7 +435,7 @@ gboolean msc_storage_scan_thread(void *data)
                }
 
                /* send notification */
-               ms_send_dir_update_noti(handle, storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
+               ms_send_dir_update_noti(update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
 
                if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP)
                        ms_set_db_status(MS_DB_STOPPED, storage_type);
@@ -857,7 +857,7 @@ gboolean msc_metadata_update(void *data)
 
        ret = __msc_dir_scan_meta_update(usr_path, INTERNAL_STORAGE_ID, scan_data->uid);
        /* send notification */
-       ms_send_dir_update_noti(handle, INTERNAL_STORAGE_ID, usr_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
+       ms_send_dir_update_noti(usr_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
        MS_SAFE_FREE(usr_path);
 
        /*__msc_dir_scan_meta_update For Each External Storage*/
@@ -882,7 +882,7 @@ gboolean msc_metadata_update(void *data)
 
                ret = __msc_dir_scan_meta_update(stg_info->stg_path, stg_info->storage_id, scan_data->uid);
                /* send notification */
-               ms_send_dir_update_noti(handle, stg_info->storage_id, stg_info->stg_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
+               ms_send_dir_update_noti(stg_info->stg_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
 
                MS_SAFE_FREE(stg_info->stg_path);
                MS_SAFE_FREE(stg_info->storage_id);