X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fmedia_folder.c;h=6e14c8b59fa49d360484f4ae7567654a80c8dd35;hb=91d04a3ff55b3f24d25ba989b12e2cc67639fb64;hp=4de07d5949a3d8c61a9fceac4d648b322b97bb37;hpb=36b68b8a618c916c3bcd35b99cc878061bb64514;p=platform%2Fcore%2Fapi%2Fmedia-content.git diff --git a/src/media_folder.c b/src/media_folder.c index 4de07d5..6e14c8b 100755 --- a/src/media_folder.c +++ b/src/media_folder.c @@ -237,7 +237,6 @@ int media_folder_update_to_db(media_folder_h folder) int ret = MEDIA_CONTENT_ERROR_NONE; content_warn("DEPRECATION WARNING: media_folder_update_to_db() is deprecated and will be removed from next release."); media_folder_s *_folder = (media_folder_s*)folder; - char repl_path[MAX_PATH_LEN] = {0, }; content_retip_if_fail(folder); content_retip_if_fail(STRING_VALID(_folder->folder_id)); @@ -245,13 +244,7 @@ int media_folder_update_to_db(media_folder_h folder) if (!g_src_path) return ret; - - ret = _media_content_replace_path(_folder->path, repl_path); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - SAFE_FREE(g_src_path); - return ret; - } - ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, repl_path, _content_get_uid()); + ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, _folder->path, _content_get_uid()); SAFE_FREE(g_src_path); return _content_error_capi(ret); @@ -262,10 +255,7 @@ int media_folder_set_name(media_folder_h folder, const char *name) int ret = MEDIA_CONTENT_ERROR_NONE; content_warn("DEPRECATION WARNING: media_folder_set_name() is deprecated and will be removed from next release."); media_folder_s *_folder = (media_folder_s*)folder; - - char *folder_path = NULL; - char new_folder_path[MAX_PATH_LEN] = {0,}; - char repl_path[MAX_PATH_LEN] = {0, }; + char *parent_folder_path = NULL; content_retip_if_fail(folder); content_retip_if_fail(STRING_VALID(name)); @@ -273,23 +263,20 @@ int media_folder_set_name(media_folder_h folder, const char *name) content_retip_if_fail(STRING_VALID(_folder->path)); content_retip_if_fail(STRING_VALID(_folder->name)); - ret = _media_content_replace_path(_folder->path, repl_path); - content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed"); - - folder_path = g_path_get_dirname(repl_path); - content_sec_debug("Existed Folder Path : %s", repl_path); - snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name); - content_sec_debug("New Path : %s", new_folder_path); + // Change name.. + g_free(_folder->name); + _folder->name = g_strdup(name); + // Change path.. g_free(g_src_path); - g_src_path = g_strdup(repl_path); - + g_src_path = g_strdup(_folder->path); g_free(_folder->path); - g_free(_folder->name); - g_free(folder_path); - _folder->path = g_strdup(new_folder_path); - _folder->name = g_strdup(name); + parent_folder_path = g_path_get_dirname(g_src_path); + _folder->path = g_strdup_printf("%s/%s", parent_folder_path, name); + g_free(parent_folder_path); + + content_sec_debug("Old[%s] New[%s]", g_src_path, _folder->path); return ret; } @@ -297,56 +284,52 @@ int media_folder_set_name(media_folder_h folder, const char *name) int media_folder_insert_to_db(const char *path) { int ret = MEDIA_CONTENT_ERROR_NONE; - char repl_path[MAX_PATH_LEN] = {0, }; char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, }; content_retip_if_fail(STRING_VALID(path)); - ret = _media_content_replace_path(path, repl_path); - content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed"); - - content_retvm_if(_media_util_is_ignorable_dir(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path"); + content_retvm_if(_media_util_is_ignorable_dir(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path"); - ret = _media_content_check_dir(repl_path); + ret = _media_content_check_dir(path); content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied"); content_retvm_if(ret == MEDIA_CONTENT_ERROR_INVALID_PARAMETER, ret, "invalid path[%s]", path); - ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid()); + ret = media_svc_get_storage_id(_content_get_db_handle(), path, storage_id, _content_get_uid()); if (ret != MS_MEDIA_ERR_NONE) { content_error("media_svc_get_storage_id failed : %d", ret); return _content_error_capi(ret); } - ret = media_svc_check_folder_exist_by_path(_content_get_db_handle(), storage_id, repl_path); + ret = media_svc_check_folder_exist_by_path(_content_get_db_handle(), storage_id, path); if (ret == MS_MEDIA_ERR_DB_NO_RECORD) { - content_sec_debug("media_svc_check_folder_exist_by_path : no record : %s", repl_path); + content_sec_debug("media_svc_check_folder_exist_by_path : no record : %s", path); ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL; - ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type); + ret = ms_user_get_storage_type(_content_get_uid(), path, &storage_type); if (ret != MS_MEDIA_ERR_NONE) { content_sec_error("ms_user_get_storage_type failed : %d", ret); return _content_error_capi(ret); } - ret = media_svc_insert_folder(_content_get_db_handle(), storage_id, storage_type, repl_path, false, _content_get_uid()); + ret = media_svc_insert_folder(_content_get_db_handle(), storage_id, storage_type, path, false, _content_get_uid()); if (ret != MS_MEDIA_ERR_NONE) { if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) { - content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path); + content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", path); ret = MEDIA_CONTENT_ERROR_NONE; } else { - content_sec_error("media_svc_insert_folder failed : %d (%s)", ret, repl_path); + content_sec_error("media_svc_insert_folder failed : %d (%s)", ret, path); } return _content_error_capi(ret); } - ret = media_svc_set_folder_scan_status(storage_id, repl_path, MEDIA_DIR_SCAN_DONE, false, _content_get_uid()); + ret = media_svc_set_folder_scan_status(storage_id, path, MEDIA_DIR_SCAN_DONE, false, _content_get_uid()); if (ret != MS_MEDIA_ERR_NONE) { content_sec_error("media_svc_set_folder_scan_status failed : %d", ret); return _content_error_capi(ret); } } else if (ret != MS_MEDIA_ERR_NONE) { - content_sec_error("media_svc_check_folder_exist_by_path failed : %d (%s)", ret, repl_path); + content_sec_error("media_svc_check_folder_exist_by_path failed : %d (%s)", ret, path); return _content_error_capi(ret); }