typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(void*, const char*, char**);
typedef int (*INSERT_BURST_ITEM)(void *, const char *, int , char **);
typedef int (*SEND_DIR_UPDATE_NOTI)(void *, const char *, char **);
+typedef int (*COUNT_DELETE_ITEMS_IN_FOLDER)(void *, const char *, int *, char **);
int
msc_load_functions(void);
int
msc_send_dir_update_noti(void **handle, const char*path);
+int
+msc_count_delete_items_in_folder(void **handle, const char*path, int *count);
+
/****************************************************************************************************
FOR BULK COMMIT
*****************************************************************************************************/
void ***func_array;
int lib_num;
void **scan_func_handle = NULL; /*dlopen handel*/
+extern int insert_count;
enum func_list {
eCHECK,
eDELETE_FOLDER,
eINSERT_BURST,
eSEND_DIR_UPDATE_NOTI,
+ eCOUNT_DELETE_ITEMS_IN_FOLDER,
eFUNC_MAX
};
"delete_all_invalid_items_in_folder",
"insert_burst_item",
"send_dir_update_noti",
+ "count_delete_items_in_folder",
};
/*init array for adding name of so*/
so_array = g_array_new(FALSE, FALSE, sizeof(char*));
MSC_DBG_ERR("[%s]", path);
MS_SAFE_FREE(err_msg);
res = MS_MEDIA_ERR_DB_INSERT_FAIL;
+ } else {
+ insert_count++;
}
} else {
/*if meta data of file exist, change valid field to "1" */
return MS_MEDIA_ERR_NONE;
}
+int
+msc_count_delete_items_in_folder(void **handle, const char*path, int *count)
+{
+ int lib_index;
+ int ret;
+ char *err_msg = NULL;
+
+ for (lib_index = 0; lib_index < lib_num; lib_index++) {
+ ret = ((COUNT_DELETE_ITEMS_IN_FOLDER)func_array[lib_index][eCOUNT_DELETE_ITEMS_IN_FOLDER])(handle[lib_index], path, count, &err_msg); /*dlopen*/
+ if (ret != 0) {
+ MSC_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
+ MS_SAFE_FREE(err_msg);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+ }
+
+ return MS_MEDIA_ERR_NONE;
+
+}
+
/****************************************************************************************************
FOR BULK COMMIT
*****************************************************************************************************/
GAsyncQueue * storage_queue;
GAsyncQueue *scan_queue;
GAsyncQueue *reg_queue;
+int insert_count;
#ifdef FMS_PERF
extern struct timeval g_mmc_start_time;
int scan_type;
int err = MS_MEDIA_ERR_NONE;
char *start_path = NULL;
- char *noti_path = NULL;
ms_storage_type_t storage_type;
storage_type = ms_get_storage_type_by_full(scan_data->msg);
err = _msc_dir_scan(handle, start_path, storage_type, scan_type);
if (err != MS_MEDIA_ERR_NONE) {
MSC_DBG_ERR("error : %d", err);
- } else {
- noti_path = strndup(scan_data->msg, scan_data->msg_size);
- msc_send_dir_update_noti(handle, noti_path);
- MS_SAFE_FREE(noti_path);
}
} else if ( scan_type == MS_MSG_STORAGE_INVALID) {
MSC_DBG_INFO("INVALID");
err = msc_invalidate_all_items(handle, storage_type);
if (err != MS_MEDIA_ERR_NONE) {
MSC_DBG_ERR("error : %d", err);
- } else {
- if (storage_type == MS_STORAGE_INTERNAL) {
- msc_send_dir_update_noti(handle, MEDIA_ROOT_PATH_INTERNAL);
- } else {
- msc_send_dir_update_noti(handle, MEDIA_ROOT_PATH_SDCARD);
- }
}
}
void **handle = NULL;
ms_storage_type_t storage_type;
int scan_type;
+ char *noti_path = NULL;
while (1) {
scan_data = g_async_queue_pop(scan_queue);
if (ret == MS_MEDIA_ERR_NONE) {
MSC_DBG_INFO("working normally");
+ int count = 0;
+
+ noti_path = strndup(scan_data->msg, scan_data->msg_size);
+ msc_count_delete_items_in_folder(handle, noti_path, &count);
+
+ MSC_DBG_INFO("delete count %d", count);
+ MSC_DBG_INFO("insert count %d", insert_count);
+
msc_delete_invalid_items_in_folder(handle, scan_data->msg);
+
+ if ( !(count == 0 && insert_count == 0)) {
+ msc_send_dir_update_noti(handle, noti_path);
+ }
+ MS_SAFE_FREE(noti_path);
}
+ insert_count = 0;
+
if (power_off) {
MSC_DBG_INFO("power off");
goto _POWEROFF;
void **handle = NULL;
ms_storage_type_t storage_type;
int scan_type;
+ char *noti_path = NULL;
while (1) {
scan_data = g_async_queue_pop(storage_queue);
}
}
+ /* send notification */
+ noti_path = strndup(scan_data->msg, scan_data->msg_size);
+ msc_send_dir_update_noti(handle, noti_path);
+ MS_SAFE_FREE(noti_path);
+
#ifdef FMS_PERF
if (storage_type == MS_STORAGE_EXTERNAL) {
ms_check_end_time(&g_mmc_end_time);