Update description about move API 24/150824/1
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 19 Sep 2017 00:49:23 +0000 (09:49 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Tue, 19 Sep 2017 00:49:23 +0000 (09:49 +0900)
Add description and processing for the same path
Add processing for already existing information

Change-Id: I1b64b19511afb58855fe92283eb5dd8a379f3e9a
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media_info.h
packaging/capi-content-media-content.spec
src/media_info.c

index 20af652..22c5c08 100755 (executable)
@@ -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
  *
index 70494c3..691fc81 100755 (executable)
@@ -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
index d55ef5f..a161367 100755 (executable)
@@ -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);
 }