[TNEXT-1108] Verify that the path is the content path 46/138046/5 accepted/tizen/unified/20170717.170051 submit/tizen/20170714.003836
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 11 Jul 2017 02:15:38 +0000 (11:15 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Thu, 13 Jul 2017 04:28:10 +0000 (04:28 +0000)
Change-Id: Ic4c0c40c68e820eea394671164b6cadc4c4ab3c1
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
packaging/capi-content-media-content.spec
src/media_content.c

index fdf19eed164a5c6617ecd6deaaf72d19737398e7..be5b02d15a7e32ce8d10b75d35c1d17965c64094 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-content-media-content
 Summary:    A Media content library in Tizen Native API
-Version:    0.3.18
+Version:    0.3.19
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index f765a141799ae64ff0169aed80156958653f87ba..87e6cec12dc752bbedb87e48d252b53f36e45544 100755 (executable)
@@ -1463,6 +1463,7 @@ int media_content_scan_folder(const char *path, bool is_recursive, media_scan_co
        bool ignore_dir = FALSE;
        char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
        char repl_path[MAX_PATH_LEN] = {0, };
+       media_svc_storage_type_e storage_type = MEDIA_SVC_STORAGE_MAX;
 
        media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
        memset(repl_path, 0, sizeof(repl_path));
@@ -1480,9 +1481,22 @@ int media_content_scan_folder(const char *path, bool is_recursive, media_scan_co
                media_content_retvm_if(ignore_dir == TRUE, 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 = media_svc_get_storage_type(repl_path, &storage_type, tzplatform_getuid(TZ_USER_NAME));
+               if (ret != MS_MEDIA_ERR_NONE) {
+                       media_content_sec_error("media_svc_get_storage_type failed : %d (%s)", ret, repl_path);
+                       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+               }
+
                media_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, tzplatform_getuid(TZ_USER_NAME));
+       if (ret != MS_MEDIA_ERR_NONE) {
+               media_content_error("media_svc_get_storage_id failed : %d", ret);
+               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       }
+
        media_content_scan_cb_data *cb_data = NULL;
        cb_data = (media_content_scan_cb_data *)malloc(sizeof(media_content_scan_cb_data));
        media_content_retvm_if(cb_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
@@ -1490,15 +1504,11 @@ 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_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, tzplatform_getuid(TZ_USER_NAME));
-       if (ret != MS_MEDIA_ERR_NONE) {
-               media_content_error("media_svc_get_storage_id failed : %d", ret);
-               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
-       }
-
        ret = media_directory_scanning_async(repl_path, storage_id, is_recursive, _media_content_scan_cb, cb_data, tzplatform_getuid(TZ_USER_NAME));
-       if (ret != MS_MEDIA_ERR_NONE)
+       if (ret != MS_MEDIA_ERR_NONE) {
                media_content_error("media_directory_scanning_async failed : %d", ret);
+               SAFE_FREE(cb_data);
+       }
 
        return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
 }