Merge function for getting thumbnail folder
[platform/core/multimedia/libmedia-service.git] / src / common / media-svc.c
index 3454c08..8787e3c 100755 (executable)
@@ -745,6 +745,7 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id
 int media_svc_delete_all_items_in_storage(const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
+       char *thumb_path = NULL;
 
        media_svc_debug("media_svc_delete_all_items_in_storage [%d]", storage_type);
 
@@ -755,25 +756,14 @@ int media_svc_delete_all_items_in_storage(const char *storage_id, media_svc_stor
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
        if (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) {
-               char *internal_thumb_path = NULL;
-               char *external_thumb_path = NULL;
-
-               ret = ms_user_get_default_thumb_store_path(uid, &internal_thumb_path);
-               ret = ms_user_get_mmc_thumb_store_path(uid, &external_thumb_path);
-
-               if (!STRING_VALID(internal_thumb_path) || !STRING_VALID(external_thumb_path)) {
+               ret = ms_user_get_thumb_store_path(uid, (ms_user_storage_type_e)storage_type, &thumb_path);
+               if (!STRING_VALID(thumb_path)) {
                        media_svc_error("fail to get thumbnail path");
-                       SAFE_FREE(internal_thumb_path);
-                       SAFE_FREE(external_thumb_path);
                        return MS_MEDIA_ERR_INTERNAL;
                }
-               const char *dirpath = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? internal_thumb_path : external_thumb_path;
 
-               /* remove thumbnails */
-               if (STRING_VALID(dirpath))
-                       ret = _media_svc_remove_all_files_in_dir(dirpath);
-               SAFE_FREE(internal_thumb_path);
-               SAFE_FREE(external_thumb_path);
+               ret = _media_svc_remove_all_files_in_dir(thumb_path);
+               SAFE_FREE(thumb_path);
                media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
        }