GAsyncQueue *reg_queue;
GMutex scan_req_mutex;
-static void __msc_clear_file_list(GPtrArray *path_array);
-
static bool __msc_is_stop_needed()
{
if (power_off) {
scan_function = (check_exists == false) ? ms_insert_item_batch : ms_validate_item;
while (dir_array->len != 0) {
+ current_path = g_ptr_array_index(dir_array, 0);
+ g_ptr_array_remove_index(dir_array, 0);
+
if (__msc_is_stop_needed()) {
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
- goto STOP_SCAN;
+ MS_SAFE_FREE(current_path);
+ continue;
}
- current_path = g_ptr_array_index(dir_array, 0);
- g_ptr_array_remove_index(dir_array, 0);
-
if (ms_check_scan_ignore(current_path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("%s is ignore", current_path);
MS_SAFE_FREE(current_path);
while ((name = g_dir_read_name(dir))) {
if (__msc_is_stop_needed()) {
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
- goto STOP_SCAN;
+ break;
}
if (name[0] == '.')
MS_SAFE_FREE(current_path);
- if (dir) {
+ if (dir)
g_dir_close(dir);
- dir = NULL;
- }
}
-STOP_SCAN:
- if (dir) {
- g_dir_close(dir);
- dir = NULL;
- }
-
- MS_SAFE_FREE(current_path);
-
- __msc_clear_file_list(dir_array);
+ g_ptr_array_free(dir_array, TRUE);
return ret;
}
return FALSE;
}
-static void __msc_clear_file_list(GPtrArray *path_array)
-{
- if (!path_array)
- return;
-
- g_ptr_array_free(path_array, TRUE);
-}
-
static int __msc_make_file_list(char *file_path, GPtrArray **path_array, uid_t uid)
{
FILE *fp = NULL;
char buf[MS_FILE_PATH_LEN_MAX] = {0,};
char *path = NULL;
int length;
+ GPtrArray *_path_array = NULL;
int ret = MS_MEDIA_ERR_NONE;
/* load the file list from file */
fp = fopen(file_path, "rt");
- if (fp == NULL) {
- MS_DBG_STRERROR("fopen failed");
- ret = MS_MEDIA_ERR_FILE_OPEN_FAIL;
- goto FREE_RESOURCE;
- }
+ MS_DBG_RETVM_IF(!fp, MS_MEDIA_ERR_FILE_OPEN_FAIL, "fopen failed");
memset(buf, 0x0, MS_FILE_PATH_LEN_MAX);
/* This is an array for storing the path of insert datas*/
- *path_array = g_ptr_array_new_with_free_func(g_free);
- if (*path_array == NULL) {
+ _path_array = g_ptr_array_new_with_free_func(g_free);
+ if (!_path_array) {
MS_DBG_ERR("g_array_new failed");
- ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
- goto FREE_RESOURCE;
+ fclose(fp);
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
/* read registering file path from stored file */
continue;
}
/* insert getted path to the list */
- g_ptr_array_add(*path_array, path);
+ g_ptr_array_add(_path_array, path);
}
if (fp) fclose(fp);
- fp = NULL;
- return MS_MEDIA_ERR_NONE;
-
-FREE_RESOURCE:
- __msc_clear_file_list(*path_array);
-
- if (fp) fclose(fp);
- fp = NULL;
+ *path_array = _path_array;
- return ret;
+ return MS_MEDIA_ERR_NONE;
}
static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid)
MS_DBG_SLOG("BULK REGISTER START [%.*s]", MAX_MSG_SIZE, register_data->msg);
ret = __msc_batch_insert(register_data->pid, path_array, register_data->uid);
- __msc_clear_file_list(path_array);
+ g_ptr_array_free(path_array, TRUE);
NEXT:
/*Active flush */