Remove path replacement function
[platform/core/api/media-content.git] / src / media_content.c
index 69df521..8d20d33 100644 (file)
@@ -195,27 +195,23 @@ int media_content_scan_file(const char *path)
        char *folder_path = NULL;
        int check_file = MEDIA_CONTENT_ERROR_NONE;
        char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0,};
-       char repl_path[MAX_PATH_LEN] = {0,};
 
        content_retip_if_fail(STRING_VALID(path));
 
        content_sec_debug("Path : %s", 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_file(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
 
-       content_retvm_if(_media_util_is_ignorable_file(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid 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);
        }
 
-       check_file = _media_util_check_file_exist(repl_path);
+       check_file = _media_util_check_file_exist(path);
        if (check_file == MEDIA_CONTENT_ERROR_NONE) {
                /* This means this path has to be inserted or refreshed */
-               folder_path = g_path_get_dirname(repl_path);
+               folder_path = g_path_get_dirname(path);
 
                if (_media_util_is_ignorable_dir(folder_path)) {
                        g_free(folder_path);
@@ -225,19 +221,19 @@ int media_content_scan_file(const char *path)
                g_free(folder_path);
 
                /* check feature */
-               content_retvm_if(!_media_util_check_support_media_type(repl_path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
+               content_retvm_if(!_media_util_check_support_media_type(path), MEDIA_CONTENT_ERROR_NOT_SUPPORTED, "Unsupported media type");
 
                ms_user_storage_type_e storage_type;
 
-               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 (%s)", ret, repl_path);
+                       content_sec_error("ms_user_get_storage_type failed : %d (%s)", ret, path);
                        return _content_error_capi(ret);
                }
-               ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
+               ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), storage_id, path);
                if (ret == MS_MEDIA_ERR_NONE) {
                        /* Refresh */
-                       ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, repl_path, _content_get_uid());
+                       ret = media_svc_refresh_item(_content_get_db_handle(), false, storage_id, storage_type, path, _content_get_uid());
                        if (ret != MS_MEDIA_ERR_NONE) {
                                content_error("media_svc_refresh_item failed : %d", ret);
                                return _content_error_capi(ret);
@@ -245,13 +241,13 @@ int media_content_scan_file(const char *path)
 
                } else if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
                        /* Insert */
-                       ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
+                       ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_id, storage_type, path, _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_item_immediately failed : %d (%s)", ret, repl_path);
+                                       content_sec_error("media_svc_insert_item_immediately failed : %d (%s)", ret, path);
                                }
 
                                return _content_error_capi(ret);
@@ -266,7 +262,7 @@ int media_content_scan_file(const char *path)
        } else {
                /* This means this path has to be deleted */
                content_debug("This path doesn't exists in file system... So now start to delete it from DB");
-               ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, repl_path, _content_get_uid());
+               ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
                if (ret != MS_MEDIA_ERR_NONE) {
                        if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
                                content_error("Does not exist in media DB also... So, this is an invalid parameter");
@@ -349,34 +345,30 @@ int media_content_scan_folder(const char *path, bool is_recursive, media_scan_co
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
-       char repl_path[MAX_PATH_LEN] = {0, };
        ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
 
        content_retip_if_fail(STRING_VALID(path));
        content_retip_if_fail(callback);
 
-       ret = _media_content_replace_path(path, repl_path);
-       content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
-
-       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");
 
        if (ret == MEDIA_CONTENT_ERROR_NONE) {
                /* If directory exist check that's ignore directory or not*/
-               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");
        } else {
                /* This means this folder has to be deleted */
                /* Or, it is real invalid path.. check storage type */
-               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 (%s)", ret, repl_path);
+                       content_sec_error("ms_user_get_storage_type failed : %d (%s)", ret, path);
                        return _content_error_capi(ret);
                }
 
                content_debug("This path doesn't exists in file system... So will be deleted it from DB");
        }
 
-       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);
@@ -388,7 +380,7 @@ int media_content_scan_folder(const char *path, bool is_recursive, media_scan_co
        cb_data->callback = callback;
        cb_data->user_data = user_data;
 
-       ret = media_directory_scanning_async(repl_path, storage_id, is_recursive, _media_content_scan_cb, cb_data, _content_get_uid());
+       ret = media_directory_scanning_async(path, storage_id, is_recursive, _media_content_scan_cb, cb_data, _content_get_uid());
        if (ret != MS_MEDIA_ERR_NONE) {
                content_error("media_directory_scanning_async failed : %d", ret);
                g_free(cb_data);
@@ -432,14 +424,10 @@ int media_content_scan_folder_v2(const char *path, bool is_recursive, media_scan
 int media_content_cancel_scan_folder(const char *path)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
-       char repl_path[MAX_PATH_LEN] = {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");
-
-       ret = media_directory_scanning_cancel(repl_path, _content_get_uid());
+       ret = media_directory_scanning_cancel(path, _content_get_uid());
        if (ret != MS_MEDIA_ERR_NONE)
                content_error("media_directory_scanning_async failed : %d", ret);