Remove unnecessary parameters 57/238557/1
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 15 Jul 2020 05:15:39 +0000 (14:15 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 15 Jul 2020 05:15:39 +0000 (14:15 +0900)
1. Remove unnecessary parameters
2. Remove unused code
3. Apply coding rule

Change-Id: I0e3688bc359d93c33044afede39b1f2e90d34d9f
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/scanner-v2/media-scanner-scan-v2.c

index 71125b8..974ef09 100644 (file)
@@ -70,8 +70,6 @@ static s_scan_item* cur_scan_item = NULL;
 int g_directory_scan_processing2 = DIR_SCAN_NON_SCAN;
 static char *g_storage_scan_path;
 static char* g_dir_scan_path;
-static unsigned int io_err_folder;
-static unsigned int io_err_storage;
 
 typedef int (*DIR_SCAN_CB)();
 static DIR_SCAN_CB g_dir_scan_cb;
@@ -87,14 +85,11 @@ struct linux_dirent {
 #define BUF_SIZE 1024
 
 static int __msc_check_stop_status(int scan_type, const char *start_path, int pid);
-static int __msc_db_update(sqlite3 *handle, const char *storage_id, const ms_comm_msg_s * scan_data);
 static int __msc_make_file_list(char *file_path, GArray **path_array, uid_t uid);
 static int __msc_batch_insert(int pid, GArray *path_array, uid_t uid);
 static int __msc_pop_register_request(GArray *register_array, ms_comm_msg_s **register_data);
 static void __msc_clear_file_list(GArray *path_array);
 static void __msc_insert_register_request(GArray *register_array, ms_comm_msg_s *insert_data);
-static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, const char*start_path, ms_user_storage_type_e storage_type, int scan_type, int pid, uid_t uid);
-static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, const char*start_path, ms_user_storage_type_e storage_type, int scan_type, int pid, uid_t uid);
 static int __msc_get_null_scan_folder_list(sqlite3 *handle, const char *stroage_id, char *path, GArray *dir_array);
 static int __msc_dir_scan_cb(void);
 static int __msc_check_scan_same_path(char *scan_path);
@@ -235,7 +230,7 @@ END:
        return ret;
 }
 
-static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, const char*start_path, ms_user_storage_type_e storage_type, int scan_type, int pid, uid_t uid)
+static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, char *start_path, int scan_type, int pid, uid_t uid)
 {
        GArray *dir_array = NULL;
        int ret = MS_MEDIA_ERR_NONE;
@@ -259,7 +254,7 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
        MS_DBG_SWARN("storage id [%s] start path [%s]", storage_id, start_path);
 
        /* make new array for storing directory */
-       dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
+       dir_array = g_array_new(FALSE, FALSE, sizeof(char *));
 
        /* add first direcotiry to directory array */
        new_start_path = g_strdup(start_path);
@@ -358,15 +353,7 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
 
                                goto STOP_SCAN;
                        }
-#if 0
-                       if (io_err_folder == MS_MAX_IO_ERR_COUNT) {
-                               MS_DBG_ERR("REACH I/O MAX COUNT[%d]", io_err_folder);
-                               if (is_recursive == true)
-                                       ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
 
-                               goto STOP_SCAN;
-                       }
-#endif
                        if (nread == 0)
                                break;
 
@@ -396,15 +383,7 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
                                        //ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
                                        goto STOP_SCAN;
                                }
-#if 0
-                               if (io_err_folder == MS_MAX_IO_ERR_COUNT) {
-                                       MS_DBG_ERR("REACH I/O MAX COUNT[%d]", io_err_folder);
-                                       if (is_recursive == true)
-                                               ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
 
-                                       goto STOP_SCAN;
-                               }
-#endif
                                d = (struct linux_dirent *) (buf + bpos);
 
                                if (d->d_name[0] == '.') {
@@ -444,9 +423,6 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
                                        ret = ms_scan_validate_item(handle, storage_id, path, uid);
                                        if (ret != MS_MEDIA_ERR_NONE) {
                                                MS_DBG_ERR("failed to update db : %d", ret);
-                                               if (ret == MS_MEDIA_ERR_INTERNAL)
-                                                       MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_folder++);
-
                                                bpos += d->d_reclen;
                                                continue;
                                        } else {
@@ -488,13 +464,8 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co
 
                                bpos += d->d_reclen;
                        }
-                       /*update modifiec type for the internal storage*/
-                       if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
-                               if (storage_type == MS_USER_STORAGE_INTERNAL)
-                                       ms_update_folder_time(handle, INTERNAL_STORAGE_ID, current_path, uid);
-                               else
-                                       ms_update_folder_time(handle, storage_id, current_path, uid);
-                       }
+                       if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE)
+                               ms_update_folder_time(handle, storage_id, current_path, uid);
                }
 
                ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_DONE, uid);
@@ -534,7 +505,7 @@ END_SCAN:
        return ret;
 }
 
-static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, const char*start_path, ms_user_storage_type_e storage_type, int scan_type, int pid, uid_t uid)
+static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, char *start_path, int scan_type, int pid, uid_t uid)
 {
        GArray *dir_array = NULL;
        int ret = MS_MEDIA_ERR_NONE;
@@ -656,12 +627,7 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
                                //ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
                                goto STOP_SCAN;
                        }
-#if 0
-                       if (io_err_storage == MS_MAX_IO_ERR_COUNT) {
-                               MS_DBG_ERR("REACH I/O MAX COUNT[%d]", io_err_storage);
-                               goto STOP_SCAN;
-                       }
-#endif
+
                        if (nread == 0)
                                break;
 
@@ -681,12 +647,7 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
                                        //ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
                                        goto STOP_SCAN;
                                }
-#if 0
-                               if (io_err_storage == MS_MAX_IO_ERR_COUNT) {
-                                       MS_DBG_ERR("REACH I/O MAX COUNT[%d]", io_err_storage);
-                                       goto STOP_SCAN;
-                               }
-#endif
+
                                d = (struct linux_dirent *) (buf + bpos);
 
                                if (d->d_name[0] == '.') {
@@ -727,9 +688,6 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
                                        ret = scan_function(handle, storage_id, path, uid);
                                        if (ret != MS_MEDIA_ERR_NONE) {
                                                MS_DBG_ERR("failed to update db : %d", scan_type);
-                                               if (ret == MS_MEDIA_ERR_INTERNAL)
-                                                       MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_storage++);
-
                                                bpos += d->d_reclen;
                                                continue;
                                        } else {
@@ -967,30 +925,21 @@ static void __msc_set_dir_scan_cur_path(char *scan_path)
 
 static int __msc_db_update(sqlite3 *handle, const char *storage_id, const ms_comm_msg_s * scan_data)
 {
-       int scan_type;
        int err = MS_MEDIA_ERR_NONE;
        char *start_path = NULL;
-       ms_user_storage_type_e storage_type;
-
-       err = ms_user_get_storage_type(scan_data->uid, scan_data->msg, &storage_type);
-       if (err != MS_MEDIA_ERR_NONE)
-               MS_DBG_ERR("ms_user_get_storage_type failed");
 
-       scan_type = scan_data->msg_type;
-
-       /*if scan type is not MS_SCAN_NONE, check data in db. */
-       if (scan_type != MS_MSG_STORAGE_INVALID) {
+       if (scan_data->msg_type != MS_MSG_STORAGE_INVALID) {
                MS_DBG_WARN("INSERT");
                start_path = g_strdup(scan_data->msg);
-               if (scan_type == MS_MSG_DIRECTORY_SCANNING || scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE)
-                       err = __msc_dir_scan_for_folder(handle, storage_id, start_path, storage_type, scan_type, scan_data->pid, scan_data->uid);
-               else if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL)
-                       err = __msc_dir_scan_for_storage(handle, storage_id, start_path, storage_type, scan_type, scan_data->pid, scan_data->uid);
+               if (scan_data->msg_type == MS_MSG_DIRECTORY_SCANNING || scan_data->msg_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE)
+                       err = __msc_dir_scan_for_folder(handle, storage_id, start_path, scan_data->msg_type, scan_data->pid, scan_data->uid);
+               else if (scan_data->msg_type == MS_MSG_STORAGE_ALL || scan_data->msg_type == MS_MSG_STORAGE_PARTIAL)
+                       err = __msc_dir_scan_for_storage(handle, storage_id, start_path, scan_data->msg_type, scan_data->pid, scan_data->uid);
 
                if (err != MS_MEDIA_ERR_NONE)
                        MS_DBG_ERR("error : %d", err);
 
-       } else if (scan_type == MS_MSG_STORAGE_INVALID) {
+       } else {
                MS_DBG_WARN("INVALID");
                msc_remove_extract_request(scan_data);
        }
@@ -1257,8 +1206,6 @@ NEXT:
 
                MS_DBG_WARN("DIRECTORY SCAN END [%d]", ret);
 
-               io_err_folder = 0;
-
                /*disconnect form media db*/
                if (handle) ms_disconnect_db(handle);
                usleep(SCAN_SLEEP_TIME);
@@ -1420,7 +1367,6 @@ NEXT:
 
                MS_DBG_WARN("STORAGE SCAN END[%d]", ret);
 
-               io_err_storage = 0;
                usleep(SCAN_SLEEP_TIME);
        }                       /*thread while*/