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;
#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);
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;
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);
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;
//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] == '.') {
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 {
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);
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;
//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;
//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] == '.') {
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 {
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);
}
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);
MS_DBG_WARN("STORAGE SCAN END[%d]", ret);
- io_err_storage = 0;
usleep(SCAN_SLEEP_TIME);
} /*thread while*/