From 7aeeace93d9435961a1a5a6273431e571fe768fb Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Tue, 19 Sep 2017 09:49:23 +0900 Subject: [PATCH] Update description about move API Add description and processing for the same path Add processing for already existing information Change-Id: I1b64b19511afb58855fe92283eb5dd8a379f3e9a Signed-off-by: Minje Ahn --- include/media_info.h | 4 +++- packaging/capi-content-media-content.spec | 2 +- src/media_info.c | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/media_info.h b/include/media_info.h index 20af652..22c5c08 100755 --- a/include/media_info.h +++ b/include/media_info.h @@ -1560,7 +1560,9 @@ int media_info_set_added_time(media_info_h media, time_t added_time) TIZEN_DEPRE /** * @brief Moves the media info to the given destination path in the media database. - * @details After moving or renaming a file in the filesystem, call this function to update the database. + * @details After moving or renaming a file in the filesystem, call this function to update the database. \n + * If the source path and destination path are the same, then this API does nothing. + * If you want to refresh media information, you should use media_content_scan_file() API. * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * diff --git a/packaging/capi-content-media-content.spec b/packaging/capi-content-media-content.spec index 70494c3..691fc81 100755 --- a/packaging/capi-content-media-content.spec +++ b/packaging/capi-content-media-content.spec @@ -1,6 +1,6 @@ Name: capi-content-media-content Summary: A Media content library in Tizen Native API -Version: 0.3.27 +Version: 0.3.28 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_info.c b/src/media_info.c index d55ef5f..a161367 100755 --- a/src/media_info.c +++ b/src/media_info.c @@ -3052,6 +3052,9 @@ int media_info_move_to_db(media_info_h media, const char* dst_path) ret = _media_content_replace_path(_media->file_path, org_repl_path); media_content_retvm_if(!STRING_VALID(org_repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed"); + /* If the two paths are the same, do nothing */ + media_content_retvm_if(g_strcmp0(repl_path, org_repl_path) == 0, MEDIA_CONTENT_ERROR_NONE, "Same path"); + ret = __media_info_check_file_validity(repl_path); media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); @@ -3079,6 +3082,20 @@ int media_info_move_to_db(media_info_h media, const char* dst_path) return _content_error_capi(MEDIA_CONTENT_TYPE, ret); } + /*Delete the media info of the dest_path if it already exists.*/ + ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path); + if (ret == MS_MEDIA_ERR_NONE) { + /* Exists */ + ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, repl_path, _content_get_uid()); + if (ret != MS_MEDIA_ERR_NONE) { + media_content_error("media_svc_delete_item_by_path failed : %d", ret); + return _content_error_capi(MEDIA_CONTENT_TYPE, ret); + } + } else if (ret != MS_MEDIA_ERR_NONE && ret != MS_MEDIA_ERR_DB_NO_RECORD) { + media_content_error("media_svc_check_item_exist_by_path failed : %d", ret); + return _content_error_capi(MEDIA_CONTENT_TYPE, ret); + } + ret = media_svc_move_item(_content_get_db_handle(), storage_id, src_storage_type, org_repl_path, dst_storage_type, repl_path, _content_get_uid()); return _content_error_capi(MEDIA_CONTENT_TYPE, ret); } -- 2.7.4