Use ms_register_start/end() directly 23/241923/3
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 20 Aug 2020 22:38:17 +0000 (07:38 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Fri, 21 Aug 2020 03:04:29 +0000 (12:04 +0900)
Use ms_register_start/end() directly instead of ms_batch_commit_disable/enable().

ms_batch_commit_enable/disable() became unnecessary due to removal of ms_validation_start/end() from scanners v1 and v2.

Change-Id: I5d59b9d409c829f9ede29757367c5ba25d8f2d0f
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
src/scanner/media-scanner-scan.c

index dc116b0..0819068 100755 (executable)
@@ -63,8 +63,6 @@ int ms_get_media_type(const char *path, int *media_type);
 bool ms_check_support_media_type(const char *path);
 void ms_register_start(bool noti_status, int pid);
 void ms_register_end(uid_t uid);
-void ms_batch_commit_enable(bool noti_enable, int pid);
-void ms_batch_commit_disable(uid_t uid);
 
 #ifdef _USE_TVPD_MODE
 int ms_cleanup_db(sqlite3 *handle, uid_t uid);
index 2902520..9bb00e7 100644 (file)
@@ -831,13 +831,3 @@ bool ms_check_support_media_type(const char *path)
 
        return true;
 }
-
-void ms_batch_commit_enable(bool noti_enable, int pid)
-{
-       ms_register_start(noti_enable, pid);
-}
-
-void ms_batch_commit_disable(uid_t uid)
-{
-       ms_register_end(uid);
-}
index 993fa96..2fa62f1 100644 (file)
@@ -223,8 +223,8 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, ch
                        goto STOP_SCAN;
                }
 
-               ms_batch_commit_disable(uid);
-               ms_batch_commit_enable(false, pid);
+               ms_register_end(uid);
+               ms_register_start(false, 0);
 
                current_path = g_ptr_array_index(dir_array, 0);
                g_ptr_array_remove_index(dir_array, 0);
@@ -376,7 +376,7 @@ END_SCAN:
 
        g_ptr_array_free(dir_array, TRUE);
 
-       ms_batch_commit_disable(uid);
+       ms_register_end(uid);
 
        if (ret != MS_MEDIA_ERR_NONE)
                MS_DBG_INFO("ret : %d", ret);
@@ -416,14 +416,14 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
 
        scan_function = (scan_type == MS_MSG_STORAGE_ALL) ? ms_scan_item_batch : ms_scan_validate_item;
 
-       ms_batch_commit_disable(uid);
+       ms_register_end(uid);
 
        while (dir_array->len != 0) {
                ret = __msc_check_stop_status(scan_type, new_start_path, pid);
                if (ret != MS_MEDIA_ERR_NONE)
                        goto STOP_SCAN;
 
-               ms_batch_commit_enable(false, pid);
+               ms_register_start(false, 0);
 
                current_path = g_ptr_array_index(dir_array, 0);
                g_ptr_array_remove_index(dir_array, 0);
@@ -532,7 +532,7 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
                        }
                }
 
-               ms_batch_commit_disable(uid);
+               ms_register_end(uid);
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_DONE, uid);
 
                if (dir) {
@@ -599,7 +599,7 @@ END_SCAN:
        __msc_set_storage_scan_cur_path(NULL);
        g_ptr_array_free(dir_array, TRUE);
 
-       ms_batch_commit_disable(uid);
+       ms_register_end(uid);
 
        if (ret != MS_MEDIA_ERR_NONE)
                MS_DBG_INFO("ret : %d", ret);
@@ -927,11 +927,11 @@ gpointer msc_directory_scan_thread(gpointer data)
                                MS_DBG_ERR("error : %d", ret);
                }
 
-               ms_batch_commit_enable(false, 0);
+               ms_register_start(false, 0);
 
                ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
 
-               ms_batch_commit_disable(scan_data->uid);
+               ms_register_end(scan_data->uid);
 
                MS_DBG_WARN("folder scan done, sent cb event path = [%.*s]", MAX_MSG_SIZE, scan_data->msg);
 
@@ -1051,7 +1051,7 @@ gpointer msc_storage_scan_thread(gpointer data)
                ms_set_db_status(MS_DB_UPDATING, storage_type);
 
                if (scan_data->msg_type != MS_MSG_STORAGE_INVALID)
-                       ms_batch_commit_enable(false, 0);
+                       ms_register_start(false, 0);
 
                if (scan_data->msg_type == MS_MSG_STORAGE_ALL) {
                        if (ms_delete_invalid_items(handle, scan_data->storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE)
@@ -1061,7 +1061,7 @@ gpointer msc_storage_scan_thread(gpointer data)
                ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
 
                if (scan_data->msg_type != MS_MSG_STORAGE_INVALID)
-                       ms_batch_commit_disable(scan_data->uid);
+                       ms_register_end(scan_data->uid);
 
                if (scan_data->msg_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE) {
                        ms_delete_invalid_folder(scan_data->storage_id, scan_data->uid);
@@ -1157,7 +1157,7 @@ static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid)
        ret = ms_connect_db(&handle, uid);
        MS_DBG_RETV_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_DB_INTERNAL);
 
-       ms_batch_commit_enable(true, pid);
+       ms_register_start(true, pid);
 
        for (i = 0; i < path_array->len; i++) {
                insert_path = g_ptr_array_index(path_array, i);
@@ -1177,7 +1177,7 @@ static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid)
        }
 
        /*call for bundle commit*/
-       ms_batch_commit_disable(uid);
+       ms_register_end(uid);
        ms_disconnect_db(handle);
 
        MS_DBG_FLEAVE();
index a7a790b..779c04c 100644 (file)
@@ -189,9 +189,9 @@ static int __msc_directory_scan_insert_only(sqlite3 *handle, ms_comm_msg_s *scan
 
        start_path = g_strdup(scan_data->msg);
 
-       ms_batch_commit_enable(false, 0);
+       ms_register_start(false, 0);
        ret = __msc_dir_scan(handle, scan_data->storage_id, start_path, false, is_recursive, scan_data->uid);
-       ms_batch_commit_disable(scan_data->uid);
+       ms_register_end(scan_data->uid);
 
        if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
                MS_DBG_INFO("working normally");
@@ -229,9 +229,9 @@ static int __msc_directory_scan_update_and_delete(sqlite3 *handle, ms_comm_msg_s
                return ret;
        }
 
-       ms_batch_commit_enable(false, 0);
+       ms_register_start(false, 0);
        ret = __msc_dir_scan(handle, scan_data->storage_id, start_path, true, is_recursive, scan_data->uid);
-       ms_batch_commit_disable(scan_data->uid);
+       ms_register_end(scan_data->uid);
 
        if (ms_delete_invalid_items(handle, scan_data->storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("deleting invalid items in storage failed");
@@ -337,9 +337,9 @@ static int __msc_storage_scan_partial(ms_comm_msg_s *scan_data, ms_user_storage_
                return ret;
        }
 
-       ms_batch_commit_enable(false, 0);
+       ms_register_start(false, 0);
        ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
-       ms_batch_commit_disable(scan_data->uid);
+       ms_register_end(scan_data->uid);
 
        if (ms_delete_invalid_items(handle, scan_data->storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("deleting invalid items in storage failed");
@@ -362,9 +362,9 @@ static int __msc_storage_scan_all(ms_comm_msg_s *scan_data, ms_user_storage_type
 
        ms_set_db_status(MS_DB_UPDATING, storage_type);
 
-       ms_batch_commit_enable(false, 0);
+       ms_register_start(false, 0);
        ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
-       ms_batch_commit_disable(scan_data->uid);
+       ms_register_end(scan_data->uid);
 
        ms_disconnect_db(handle);
 
@@ -483,7 +483,7 @@ static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid)
        ret = ms_connect_db(&handle, uid);
        MS_DBG_RETV_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_DB_INTERNAL);
 
-       ms_batch_commit_enable(true, pid);
+       ms_register_start(true, pid);
 
        for (i = 0; i < path_array->len; i++) {
                insert_path = g_ptr_array_index(path_array, i);
@@ -502,8 +502,7 @@ static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid)
                }
        }
 
-       /*call for bundle commit*/
-       ms_batch_commit_disable(uid);
+       ms_register_end(uid);
        ms_disconnect_db(handle);
 
        MS_DBG_FLEAVE();