typedef int (*DELETE_ITEM)(void *, const char *, const char *, uid_t, char **);
typedef int (*DELETE_ALL_ITEMS_IN_STORAGE)(void *, const char *, int, uid_t, char **);
typedef int (*DELETE_ALL_INVALID_ITMES_IN_STORAGE)(void *, const char *, int, uid_t, char **);
+typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(void *, const char *, const char *, bool, uid_t, char**);
typedef int (*UPDATE_FOLDER_TIME)(void *, const char *, const char *, uid_t, char **);
typedef int (*GET_STORAGE_ID)(void *, const char *, char *, uid_t uid, char **);
typedef int (*SET_STORAGE_SCAN_STATUS)(void *, const char *, int, uid_t, char **);
typedef int (*UPDATE_ITEM_BEGIN)(void *, int, char **);
typedef int (*UPDATE_ITEM_END)(void *, uid_t, char **);
+typedef int (*DELETE_INVALID_FOLDER_BY_PATH)(void *, const char *, const char *, uid_t, char **);
typedef int (*CHECK_FOLDER_EXIST)(void*, const char*, const char*, char **);
typedef int (*GET_FOLDER_ID)(void *, const char *, const char *, char *, char **);
typedef int (*GET_EXTRACT_LIST)(void*, const char*, int, int, const char*, int, uid_t, void*, char**);
int ms_validaty_change_all_items(void **handle, const char *storage_id, ms_user_storage_type_e storage_type, bool validity, uid_t uid);
bool ms_delete_invalid_items(void **handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid);
int ms_set_folder_item_validity(void **handle, const char *storage_id, const char *path, int validity, int recursive, uid_t uid);
+int ms_delete_invalid_items_in_folder(void **handle, const char *storage_id, const char *path, bool is_recursive, uid_t uid);
int ms_send_dir_update_noti(void **handle, const char *storage_id, const char *path, const char *folder_id, ms_noti_type_e noti_type, int pid);
int ms_update_folder_time(void **handle, const char *storage_id, char *folder_path, uid_t uid);
int ms_get_storage_id(void **handle, const char *path, char *storage_id, uid_t uid);
int ms_set_storage_validity(void **handle, const char *storage_id, int validity, uid_t uid);
int ms_set_all_storage_validity(void **handle, int validity, uid_t uid);
int ms_update_meta_batch(void **handle, const char *path, const char *storage_id, uid_t uid);
+int ms_delete_invalid_folder_by_path(void **handle, const char *storage_id, const char *folder_path, uid_t uid);
int ms_check_folder_exist(void **handle, const char *storage_id, const char *folder_path);
int ms_get_folder_id(void **handle, const char *storage_id, const char *path, char **folder_id);
int ms_get_media_type(void **handle, const char *path, int *media_type);
eDELETE_INVALID_ITEMS,
eSET_FOLDER_ITEM_VALIDITY,
eINSERT_BURST,
+ eDELETE_FOLDER,
eSEND_DIR_UPDATE_NOTI,
eDELETE_ITEM,
eUPDATE_FOLDER_TIME,
eUPDATE_ITEM_META,
eUPDATE_ITEM_BEGIN,
eUPDATE_ITEM_END,
+ eDELETE_INVALID_FOLDER_BY_PATH,
eCHECK_FOLDER_EXIST,
eGET_FOLDER_ID,
eGET_MEDIA_TYPE,
"delete_all_invalid_items_in_storage",
"set_folder_item_validity",
"insert_burst_item",
+ "delete_all_invalid_items_in_folder",
"send_dir_update_noti",
"delete_item",
"update_folder_time",
"update_item_meta",
"update_item_begin",
"update_item_end",
+ "delete_invalid_folder_by_path",
"check_folder_exist",
"get_folder_id",
"get_media_type",
return MS_MEDIA_ERR_NONE;
}
+int ms_delete_invalid_items_in_folder(void **handle, const char* storage_id, const char*path, bool is_recursive, uid_t uid)
+{
+ int lib_index;
+ int ret;
+ char *err_msg = NULL;
+
+ for (lib_index = 0; lib_index < lib_num; lib_index++) {
+ ret = ((DELETE_ALL_INVALID_ITEMS_IN_FOLDER)func_array[lib_index][eDELETE_FOLDER])(handle[lib_index], storage_id, path, is_recursive, uid, &err_msg); /*dlopen*/
+ if (ret != 0) {
+ MS_DBG_ERR("error : %s [%s]", g_array_index(so_array, char*, lib_index), err_msg);
+ MS_SAFE_FREE(err_msg);
+ return MS_MEDIA_ERR_DB_UPDATE_FAIL;
+ }
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
int ms_send_dir_update_noti(void **handle, const char* storage_id, const char*path, const char*folder_id, ms_noti_type_e noti_type, int pid)
{
int lib_index;
return res;
}
+int ms_delete_invalid_folder_by_path(void **handle, const char *storage_id, const char *folder_path, uid_t uid)
+{
+ int lib_index;
+ int res = MS_MEDIA_ERR_NONE;
+ int ret;
+ char *err_msg = NULL;
+
+ for (lib_index = 0; lib_index < lib_num; lib_index++) {
+ ret = ((DELETE_INVALID_FOLDER_BY_PATH)func_array[lib_index][eDELETE_INVALID_FOLDER_BY_PATH])(handle[lib_index], storage_id, folder_path, uid, &err_msg); /*dlopen*/
+ if (ret != 0) {
+ MS_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, storage_id);
+ MS_SAFE_FREE(err_msg);
+ res = MS_MEDIA_ERR_DB_INSERT_FAIL;
+ }
+ }
+
+ return res;
+}
+
int ms_check_folder_exist(void **handle, const char *storage_id, const char *folder_path)
{
int lib_index;
ms_dir_scan_status_e scan_status = MS_DIR_SCAN_NONE;
ms_noti_type_e noti_type = MS_ITEM_INSERT;
char *folder_uuid = NULL;
+ bool is_recursive = true;
uid_t uid = MEDIA_DEFAULT_UID;
while (1) {
ms_trim_dir_path(scan_data->msg);
if (g_file_test(scan_data->msg, G_FILE_TEST_IS_DIR)) {
+ is_recursive = (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) ? false : true;
if (ms_check_folder_exist(handle, storage_id, scan_data->msg) == MS_MEDIA_ERR_NONE) {
/*already exist in media DB*/
noti_type = MS_ITEM_UPDATE;
}
} else {
/*directory is deleted*/
+ is_recursive = true;
noti_type = MS_ITEM_DELETE;
scan_type = MS_MSG_DIRECTORY_SCANNING;
scan_data->msg_type = MS_MSG_DIRECTORY_SCANNING;
__msc_call_dir_scan_cb();
/*delete invalid folder first, then delete invalid item, avoid to folder was deleted but item not when unmount*/
- if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
+ /*if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("deleting invalid folders in storage failed");
if (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid))
- MS_DBG_ERR("deleting invalid items in storage failed");
+ MS_DBG_ERR("deleting invalid items in storage failed");*/
+
+ /*revert to 3.0,folder scan should only delete invalid in folder instead of delete invalid in storage*/
+ if (ms_delete_invalid_items_in_folder(handle, storage_id, scan_data->msg, is_recursive, uid) != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("deleting invalid items in folder failed");
+ }
/*if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
SCAN_DONE:
MS_DBG_WARN("storage_id = [%s], dir Path = [%.*s], pid = [%d]", storage_id, MAX_MSG_SIZE, scan_data->msg, scan_data->pid);
if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
+ /*remove invalid folder in folder table.*/
+ if (is_recursive == true) {
+ if (ms_delete_invalid_folder_by_path(handle, storage_id, scan_data->msg, uid) != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("deleting invalid folder failed");
+ }
+ }
if (noti_type == MS_ITEM_DELETE) {
ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
}