Remove plugin API for folder batch insertion 95/237295/6 accepted/tizen/unified/20200630.131149 submit/tizen/20200630.065716
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 29 Jun 2020 01:21:47 +0000 (10:21 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Tue, 30 Jun 2020 01:59:04 +0000 (01:59 +0000)
This patch changes media-scanner-v2 to write directly to media.db.
It makes better performance than bulk insert through IPC.

Change-Id: Ia91b44d8707b32d4c347c1b152b5225da6dbad17
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/include/media-common-db-svc.h
src/common/media-common-db-svc.c
src/scanner-v2/media-scanner-scan-v2.c

index 494df63..89d6c55 100755 (executable)
@@ -51,8 +51,6 @@ typedef int (*GET_STORAGE_ID)(sqlite3 *, const char *, char *, uid_t uid);
 typedef int (*SET_STORAGE_SCAN_STATUS)(sqlite3 *, const char *, int, uid_t);
 typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, int, uid_t);
 typedef int (*SET_FOLDER_VALIDITY)(sqlite3 *, const char *, const char *, int, bool, uid_t);
-typedef int (*INSERT_FOLDER_BEGIN)(int);
-typedef int (*INSERT_FOLDER_END)(uid_t);
 typedef int (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, int, uid_t);
 typedef int (*GET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int *);
 typedef int (*SET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int, uid_t);
@@ -123,8 +121,6 @@ void ms_register_start(bool noti_status, int pid);
 void ms_register_end(uid_t uid);
 void ms_validate_start(void);
 void ms_validate_end(uid_t uid);
-void ms_insert_folder_start(void);
-void ms_insert_folder_end(uid_t uid);
 
 int ms_get_extract_list(sqlite3 *handle, const char* storage_id, int storage_type, int scan_type, const char* path, int is_end, uid_t uid, void* array);
 int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, int storage_type, void* data);
index 346f74e..f2fe040 100644 (file)
@@ -53,8 +53,6 @@ enum func_list {
        eSET_STORAGE_SCAN_STATUS,
        eINSERT_FOLDER,
        eSET_FOLDER_VALIDITY,
-       eINSERT_FOLDER_BEGIN,
-       eINSERT_FOLDER_END,
        eGET_FOLDER_SCAN_STATUS,
        eSET_FOLDER_SCAN_STATUS,
        eCHECK_FOLDER_MODIFIED,
@@ -97,8 +95,6 @@ int ms_load_functions(void)
                "set_storage_scan_status",
                "insert_folder",
                "set_folder_validity",
-               "insert_folder_begin",
-               "insert_folder_end",
                "get_folder_scan_status",
                "set_folder_scan_status",
                "check_folder_modified",
@@ -154,7 +150,6 @@ int ms_connect_db(sqlite3 **handle, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
 
-       /*Lock mutex for openning db*/
        g_mutex_lock(&db_mutex);
 
        ret = media_db_connect(handle, uid, false);
@@ -760,24 +755,6 @@ void ms_validate_end(uid_t uid)
                MS_DBG_ERR("SET_ITEM_VALIDITY_END failed [%d]", ret);
 }
 
-void ms_insert_folder_start(void)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((INSERT_FOLDER_BEGIN)func_array[eINSERT_FOLDER_BEGIN])(MSC_REGISTER_COUNT);/*dlopen*/
-       if (ret != MS_MEDIA_ERR_NONE)
-               MS_DBG_ERR("INSERT_FOLDER_BEGIN failed [%d]", ret);
-}
-
-void ms_insert_folder_end(uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((INSERT_FOLDER_END)func_array[eINSERT_FOLDER_END])(uid);/*dlopen*/
-       if (ret != MS_MEDIA_ERR_NONE)
-               MS_DBG_ERR("INSERT_FOLDER_END failed [%d]", ret);
-}
-
 int ms_get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *scan_status)
 {
        int ret = MS_MEDIA_ERR_NONE;
index 2a25932..694a426 100644 (file)
@@ -275,7 +275,6 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
 
        //MS_DBG_ERR("new start path [%s]", new_start_path);
        g_array_append_val(dir_array, start_path);
-       ms_insert_folder_end(uid);
 
        is_recursive = (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) ? false : true;
 
@@ -339,7 +338,6 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
                        goto STOP_SCAN;
                }
 
-               ms_insert_folder_start();
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_PROCESSING, uid);
                sleep_count = 0;
 
@@ -522,7 +520,6 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
                        }
                }
 
-               ms_insert_folder_end(uid);
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_DONE, uid);
 
                if (fd != -1) {
@@ -539,7 +536,6 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
 
 STOP_SCAN:
        MS_DBG_ERR("stop folder scan...");
-       ms_insert_folder_end(uid);
        ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
        MS_SAFE_FREE(current_path);
 
@@ -593,7 +589,6 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
        new_start_path = g_strdup(start_path);
 
        g_array_append_val(dir_array, start_path);
-       ms_insert_folder_end(uid);
        if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("insert folder failed");
 
@@ -657,7 +652,6 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
                        }
                }
 
-               ms_insert_folder_start();
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_PROCESSING, uid);
                sleep_count = 0;
 
@@ -784,7 +778,6 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
                        }
                }
 
-               ms_insert_folder_end(uid);
                /*commit to db before set scan done, fix timing issue storage scan, then folder scan for same folder*/
                ms_batch_commit_disable(true, true, uid);
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_DONE, uid);
@@ -858,7 +851,6 @@ NEXT_SCAN:
        goto EXIT;
 
 STOP_SCAN:
-       ms_insert_folder_end(uid);
        if (current_path != NULL)
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
        MS_SAFE_FREE(current_path);