uuid related fuctions cleanup 09/227609/1
authorMinje Ahn <minje.ahn@samsung.com>
Fri, 13 Mar 2020 06:05:17 +0000 (15:05 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Fri, 13 Mar 2020 06:05:17 +0000 (15:05 +0900)
Change-Id: Ibf6c1c4a9d80e5edc66ef1b47ea7c80506410e4e
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-svc.h
plugin/media-content-plugin.c
src/common/media-svc-media-folder.c
src/common/media-svc-util.c
src/common/media-svc.c

index 8cfe931..8be0e94 100755 (executable)
@@ -61,7 +61,6 @@ int media_svc_get_pinyin(const char *src_str, char **pinyin_str);
 int media_svc_check_pinyin_support(bool *support);
 int media_svc_update_item_meta(sqlite3 *handle, uid_t uid);
 
-int media_svc_generate_uuid(char **uuid);
 int media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity);
 int media_svc_insert_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid);
 int media_svc_update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid);
index 0e057f7..afd1e93 100755 (executable)
@@ -93,7 +93,8 @@ int update_folder_time(sqlite3 *handle, const char *storage_id, char *folder_pat
 
 int get_uuid(char **uuid)
 {
-       return media_svc_generate_uuid(uuid);
+       /* For scanner V2 */
+       return MS_MEDIA_ERR_NONE;
 }
 
 int check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
index 3b399ef..2c50926 100755 (executable)
@@ -152,6 +152,7 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, bool is_dir
 
        if (STRING_VALID(folder_uuid)) {
                SAFE_STRLCPY(folder_id, folder_uuid, MEDIA_SVC_UUID_SIZE + 1);
+               SAFE_FREE(folder_uuid);
        } else {
                media_svc_error("Fail to get folder_uuid");
                return MS_MEDIA_ERR_INTERNAL;
index dfb5986..43dc6d1 100644 (file)
@@ -133,7 +133,7 @@ static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
 char *_media_info_generate_uuid(void)
 {
        uuid_t uuid_value;
-       static char uuid_unparsed[37];
+       char uuid_unparsed[37];
 
 RETRY_GEN:
        uuid_generate(uuid_value);
@@ -144,7 +144,7 @@ RETRY_GEN:
                goto RETRY_GEN;
        }
 
-       return uuid_unparsed;
+       return g_strdup(uuid_unparsed);
 }
 
 static int __media_svc_split_to_double(char *input, double *arr)
@@ -727,7 +727,6 @@ int _media_svc_get_file_time(const char *full_path)
 int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, bool refresh)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       char * media_uuid = NULL;
        bool drm_type = false;
        char mime_type[256] = {0, };
        media_svc_media_type_e media_type;
@@ -760,13 +759,7 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
        content_info->storage_type = storage_type;
        time(&content_info->added_time);
 
-       media_uuid = _media_info_generate_uuid();
-       if (media_uuid == NULL) {
-               _media_svc_destroy_content_info(content_info);
-               return MS_MEDIA_ERR_INTERNAL;
-       }
-
-       content_info->media_uuid = g_strdup(media_uuid);
+       content_info->media_uuid = _media_info_generate_uuid();
        media_svc_retv_del_if(content_info->media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
        content_info->file_name = g_path_get_basename(path);
@@ -1719,7 +1712,7 @@ int _media_svc_get_media_type(const char *path, int *mediatype)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char mime_type[256] = {0};
-       media_svc_media_type_e media_type =  MEDIA_SVC_MEDIA_TYPE_OTHER;
+       media_svc_media_type_e media_type = MEDIA_SVC_MEDIA_TYPE_OTHER;
 
        media_svc_retvm_if(mediatype == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "mediatype is NULL");
 
index 55fb6ce..e018f44 100755 (executable)
@@ -671,17 +671,6 @@ int media_svc_get_storage_id(sqlite3 *handle, const char *path, char *storage_id
        return _media_svc_get_storage_uuid(handle, path, storage_id, uid);
 }
 
-int media_svc_generate_uuid(char **uuid)
-{
-       char *gen_uuid = NULL;
-       gen_uuid = _media_info_generate_uuid();
-       media_svc_retvm_if(gen_uuid == NULL, MS_MEDIA_ERR_INTERNAL, "Fail to generate uuid");
-
-       *uuid = strdup(gen_uuid);
-
-       return MS_MEDIA_ERR_NONE;
-}
-
 int media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity)
 {
        return _media_svc_check_storage(handle, storage_id, storage_path, validity);