[ACR-1189] Modified media move operation 60/173960/3 accepted/tizen/unified/20180403.060122 submit/tizen/20180402.053402
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 27 Mar 2018 07:43:04 +0000 (16:43 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 28 Mar 2018 07:54:20 +0000 (16:54 +0900)
Modified to support USB storage

Change-Id: Id0f874109f83c658a91a92a9b349eb85843e729e
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-svc.h
packaging/libmedia-service.spec
src/common/media-svc-media-folder.c
src/common/media-svc-media.c
src/common/media-svc.c
src/include/common/media-svc-media-folder.h
src/include/common/media-svc-media.h
test/media-service-test.c

index 828352b..2a3c0f8 100755 (executable)
@@ -44,7 +44,7 @@ int media_svc_insert_item_begin(int with_noti, int data_cnt, int from_pid);
 int media_svc_insert_item_end(uid_t uid);
 int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, int is_burst, uid_t uid);
 int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid);
-int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e src_storage, const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path, uid_t uid);
+int media_svc_move_item(MediaSvcHandle *handle, const char *src_path, const char *dest_path, uid_t uid);
 int media_svc_set_item_validity_begin(int data_cnt);
 int media_svc_set_item_validity_end(uid_t uid);
 int media_svc_set_item_validity(const char *storage_id, const char *path, int validity, uid_t uid);
@@ -102,7 +102,7 @@ int media_svc_append_query(const char *query, uid_t uid);
 int media_svc_send_query(uid_t uid);
 
 int media_svc_get_media_type(const char *path, int *mediatype);
-int media_svc_create_thumbnail(const char *file_path, int media_type, uid_t uid, char **thumbnail_path);
+int media_svc_create_thumbnail(const char *storage_id, const char *file_path, int media_type, uid_t uid, char **thumbnail_path);
 
 #ifdef __cplusplus
 }
index 1f91fa3..17253bc 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
-Version: 0.3.28
+Version: 0.3.29
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0 and PD
index 6d74c3f..f8003ba 100755 (executable)
@@ -29,7 +29,6 @@
 
 #define FOLDER_SCAN_DONE 4
 
-extern __thread GList *g_media_svc_move_item_query_list;
 static __thread GList *g_media_svc_insert_folder_query_list;
 
 int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid)
@@ -115,7 +114,7 @@ static int __media_svc_append_folder(const char *storage_id, media_svc_storage_t
        return ret;
 }
 
-int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, bool stack_query, uid_t uid)
+int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        int modified_time = 0;
@@ -124,12 +123,8 @@ int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uui
 
        char *sql = sqlite3_mprintf("UPDATE %q SET modified_time=%d WHERE folder_uuid=%Q;", MEDIA_SVC_DB_TABLE_FOLDER, modified_time, folder_uuid);
 
-       if (!stack_query) {
-               ret = _media_svc_sql_query(sql, uid);
-               SQLITE3_SAFE_FREE(sql);
-       } else {
-               _media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
-       }
+       ret = _media_svc_sql_query(sql, uid);
+       SQLITE3_SAFE_FREE(sql);
 
        return ret;
 }
@@ -301,20 +296,6 @@ int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *sto
        return ret;
 }
 
-int _media_svc_update_folder_table(const char *storage_id, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       char *sql = NULL;
-
-       sql = sqlite3_mprintf("DELETE FROM %q WHERE folder_uuid IN (SELECT folder_uuid FROM '%q' WHERE folder_uuid NOT IN (SELECT folder_uuid FROM '%q'));",
-               MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_FOLDER, storage_id);
-
-       ret = _media_svc_sql_query(sql, uid);
-       SQLITE3_SAFE_FREE(sql);
-
-       return ret;
-}
-
 int _media_svc_get_folder_info_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, time_t *modified_time)
 {
        int ret = MS_MEDIA_ERR_NONE;
index df7c690..d54c923 100755 (executable)
 
 static __thread GList *g_media_svc_item_validity_query_list = NULL;
 static __thread GList *g_media_svc_insert_item_query_list = NULL;
-__thread GList *g_media_svc_move_item_query_list = NULL;
 static __thread GList *g_media_svc_update_item_query_list = NULL;
 static __thread GList *g_media_svc_update_list = NULL;
 
-static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, media_svc_storage_type_e storage_type, GArray **thumb_path)
+static int __media_svc_get_invalid_records_with_thumbnail(sqlite3 *handle, const char *storage_id, GArray **thumb_path)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3_stmt *sql_stmt = NULL;
-       char *sql = sqlite3_mprintf("SELECT thumbnail_path FROM '%q' WHERE validity=0 AND storage_type=%d AND thumbnail_path IS NOT NULL", MEDIA_SVC_DB_TABLE_MEDIA, storage_type);
+       char *sql = sqlite3_mprintf("SELECT thumbnail_path FROM '%q' WHERE validity=0 AND thumbnail_path IS NOT NULL", storage_id);
 
        media_svc_debug("[SQL query] : %s", sql);
 
@@ -487,7 +486,7 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, med
 
        /*If external USB, no need this process */
        if (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) {
-               ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_type, &thumb_list);
+               ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_id, &thumb_list);
                if (ret != MS_MEDIA_ERR_NONE) {
                        media_svc_error("error when get thumbnail record");
                        g_array_free(thumb_list, false);
@@ -495,7 +494,7 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, med
                        return ret;
                }
        }
-
+       /* MMC FIX:: Remove storage_type from query */
        char *sql = sqlite3_mprintf("DELETE FROM '%q' WHERE validity = 0 AND storage_type = %d;", storage_id, storage_type);
 
        ret = _media_svc_sql_query(sql, uid);
@@ -616,31 +615,34 @@ int _media_svc_update_recursive_folder_item_validity(const char *storage_id, con
        return ret;
 }
 
-int _media_svc_update_item_by_path(const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path,
-                               const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query, uid_t uid)
+int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, media_svc_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, uid_t uid)
 {
        /* update path, filename, modified_time, folder_uuid, thumbnail_path, */
        /* played_count, last_played_time, last_played_position, favourite, storaget_type*/
 
+       /* NOTICE (This operation is abnormal. Modifications should be cautious.)
+       1. Update source to destination info
+       2. Insert destination table
+       3. Remove source info
+       */
        int ret = MS_MEDIA_ERR_NONE;
-       char *sql = NULL;
+       char *update = sqlite3_mprintf("UPDATE '%q' SET path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, storage_type=%d, storage_uuid='%q', played_count=0, last_played_time=0, last_played_position=0 WHERE path=%Q;",
+                               org_storage_id, dest_path, file_name, modified_time, folder_uuid, dest_storage, dst_storage_id, src_path);
+       char *insert = sqlite3_mprintf("INSERT OR REPLACE INTO '%q' SELECT * FROM '%q' WHERE path = '%q';", dst_storage_id, org_storage_id, dest_path);
+       char *remove = sqlite3_mprintf("DELETE FROM '%q' WHERE path = '%q';", org_storage_id, dest_path);
+       char *query = NULL;
+
+       if (strcmp(org_storage_id, dst_storage_id) != 0)
+               query = sqlite3_mprintf("%s %s %s", update, insert, remove);
+       else
+               query = sqlite3_mprintf("%s %s", update, insert);
 
-       if (thumb_path != NULL) {
-               sql = sqlite3_mprintf("UPDATE '%q' SET path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, thumbnail_path=%Q, storage_type=%d, \
-                                       played_count=0, last_played_time=0, last_played_position=0 WHERE path=%Q;",
-                                       MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, thumb_path, dest_storage, src_path);
-       } else {
-               sql = sqlite3_mprintf("UPDATE '%q' SET path=%Q, file_name=%Q, modified_time=%d, folder_uuid=%Q, storage_type=%d, \
-                                       played_count=0, last_played_time=0, last_played_position=0 WHERE path=%Q;",
-                                       MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, dest_storage, src_path);
-       }
+       SQLITE3_SAFE_FREE(update);
+       SQLITE3_SAFE_FREE(insert);
+       SQLITE3_SAFE_FREE(remove);
 
-       if (!stack_query) {
-               ret = _media_svc_sql_query(sql, uid);
-               SQLITE3_SAFE_FREE(sql);
-       } else {
-               _media_svc_sql_query_add(&g_media_svc_move_item_query_list, &sql);
-       }
+       ret = _media_svc_sql_query(query, uid);
+       SQLITE3_SAFE_FREE(query);
 
        return ret;
 }
@@ -660,8 +662,6 @@ int _media_svc_list_query_do(media_svc_query_type_e query_type, uid_t uid)
 
        if (query_type == MEDIA_SVC_QUERY_SET_ITEM_VALIDITY)
                ret = _media_svc_sql_query_list(&g_media_svc_item_validity_query_list, uid);
-       else if (query_type == MEDIA_SVC_QUERY_MOVE_ITEM)
-               ret = _media_svc_sql_query_list(&g_media_svc_move_item_query_list, uid);
        else if (query_type == MEDIA_SVC_QUERY_INSERT_ITEM)
                ret = _media_svc_sql_query_list(&g_media_svc_insert_item_query_list, uid);
        else if (query_type == MEDIA_SVC_QUERY_UPDATE_ITEM)
index 3d03e70..b131670 100755 (executable)
@@ -36,9 +36,6 @@
 static __thread int g_media_svc_item_validity_data_cnt = 1;
 static __thread int g_media_svc_item_validity_cur_data_cnt = 0;
 
-static __thread int g_media_svc_move_item_data_cnt = 1;
-static __thread int g_media_svc_move_item_cur_data_cnt = 0;
-
 static __thread int g_media_svc_insert_item_data_cnt = 1;
 static __thread int g_media_svc_insert_item_cur_data_cnt = 0;
 
@@ -468,8 +465,7 @@ int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storag
        return ret;
 }
 
-int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e src_storage, const char *src_path,
-                       media_svc_storage_type_e dest_storage, const char *dest_path, uid_t uid)
+int media_svc_move_item(MediaSvcHandle *handle, const char *src_path, const char *dest_path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *db_handle = (sqlite3 *)handle;
@@ -478,7 +474,10 @@ int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_sv
        int modified_time = 0;
        char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
        char old_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0, };
-       char new_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0, };
+       char org_stg_id[MEDIA_SVC_UUID_SIZE + 1] = {0, };
+       char dst_stg_id[MEDIA_SVC_UUID_SIZE + 1] = {0, };
+       ms_user_storage_type_e org_stg_type = MS_USER_STORAGE_INTERNAL;
+       ms_user_storage_type_e dst_stg_type = MS_USER_STORAGE_INTERNAL;
        int media_type = -1;
 
        media_svc_debug_fenter();
@@ -486,11 +485,20 @@ int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_sv
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(src_path), MS_MEDIA_ERR_INVALID_PARAMETER, "src_path is NULL");
        media_svc_retvm_if(!STRING_VALID(dest_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dest_path is NULL");
-       media_svc_retvm_if(__media_svc_check_storage(src_storage) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid src_storage");
-       media_svc_retvm_if(__media_svc_check_storage(dest_storage) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid dest_storage");
+
+       /* Get storage_id */
+       ret = _media_svc_get_storage_uuid(db_handle, src_path, org_stg_id, uid);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+       ret = _media_svc_get_storage_uuid(db_handle, dest_path, dst_stg_id, uid);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+       /* Get storage_type */
+       ret = ms_user_get_storage_type(uid, src_path, &org_stg_type);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+       ret = ms_user_get_storage_type(uid, dest_path, &dst_stg_type);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
        /*check and update folder*/
-       ret = _media_svc_get_and_append_folder_id_by_path(db_handle, storage_id, dest_path, dest_storage, folder_uuid, uid);
+       ret = _media_svc_get_and_append_folder_id_by_path(db_handle, dst_stg_id, dest_path, dst_stg_type, folder_uuid, uid);
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
        /*get filename*/
@@ -499,110 +507,48 @@ int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_sv
        /*get modified_time*/
        modified_time = _media_svc_get_file_time(dest_path);
 
-       /*get thumbnail_path to update. only for Imgae and Video items. Audio share album_art(thumbnail)*/
-       ret = _media_svc_get_media_type_by_path(db_handle, storage_id, src_path, &media_type);
+       ret = _media_svc_get_media_type_by_path(db_handle, org_stg_id, src_path, &media_type);
        if (ret != MS_MEDIA_ERR_NONE) {
                media_svc_error("_media_svc_get_media_type_by_path failed");
                SAFE_FREE(file_name);
                return ret;
        }
 
-       if ((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) {
-               /*get old thumbnail_path*/
-               ret = _media_svc_get_thumbnail_path_by_path(db_handle, src_path, old_thumb_path);
-               if ((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD)) {
-                       media_svc_error("_media_svc_get_thumbnail_path_by_path failed");
-                       SAFE_FREE(file_name);
-                       return ret;
-               }
-
-               _media_svc_get_thumbnail_path(dest_storage, media_type, new_thumb_path, dest_path, THUMB_EXT, uid);
-       }
-
-       if (g_media_svc_move_item_data_cnt == 1) {
-
-               /*update item*/
-               if ((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO))
-                       ret = _media_svc_update_item_by_path(src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, FALSE, uid);
-               else
-                       ret = _media_svc_update_item_by_path(src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, FALSE, uid);
-
-               SAFE_FREE(file_name);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-               media_svc_debug("Move is successful. Sending noti for this");
-
-               /* Get notification info */
-               media_svc_noti_item *noti_item = NULL;
-               ret = _media_svc_get_noti_info(db_handle, storage_id, dest_path, MS_MEDIA_ITEM_FILE, &noti_item);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-               /* Send notification for move */
-               _media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, src_path, media_type, noti_item->media_uuid, noti_item->mime_type);
-               _media_svc_destroy_noti_item(noti_item);
-
-               /*update folder modified_time*/
-               folder_path = g_path_get_dirname(dest_path);
-               ret = _media_svc_update_folder_modified_time_by_folder_uuid(folder_uuid, folder_path, FALSE, uid);
-               SAFE_FREE(folder_path);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-               ret = _media_svc_update_folder_table(storage_id, uid);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-       } else if (g_media_svc_move_item_cur_data_cnt < (g_media_svc_move_item_data_cnt - 1)) {
-
-               /*update item*/
-               if ((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO))
-                       ret = _media_svc_update_item_by_path(src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, TRUE, uid);
-               else
-                       ret = _media_svc_update_item_by_path(src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, TRUE, uid);
-
+       /*get old thumbnail_path and remove thumbnail */
+       ret = _media_svc_get_thumbnail_path_by_path(db_handle, src_path, old_thumb_path);
+       if ((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD)) {
+               media_svc_error("_media_svc_get_thumbnail_path_by_path failed");
                SAFE_FREE(file_name);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-               /*update folder modified_time*/
-               folder_path = g_path_get_dirname(dest_path);
-               ret = _media_svc_update_folder_modified_time_by_folder_uuid(folder_uuid, folder_path, TRUE, uid);
-               SAFE_FREE(folder_path);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-               g_media_svc_move_item_cur_data_cnt++;
-
-       } else if (g_media_svc_move_item_cur_data_cnt == (g_media_svc_move_item_data_cnt - 1)) {
-               /*update item*/
-               if ((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO))
-                       ret = _media_svc_update_item_by_path(src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, new_thumb_path, TRUE, uid);
-               else
-                       ret = _media_svc_update_item_by_path(src_path, dest_storage, dest_path, file_name, modified_time, folder_uuid, NULL, TRUE, uid);
+               return ret;
+       }
 
-               SAFE_FREE(file_name);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+       if (STRING_VALID(old_thumb_path)) {
+               ret = _media_svc_remove_file(old_thumb_path);
+               if (ret != MS_MEDIA_ERR_NONE)
+                       media_svc_error("_media_svc_remove_file failed : %d", ret);
+       }
 
-               /*update folder modified_time*/
-               folder_path = g_path_get_dirname(dest_path);
-               ret = _media_svc_update_folder_modified_time_by_folder_uuid(folder_uuid, folder_path, TRUE, uid);
-               SAFE_FREE(folder_path);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+       /*move item*/
+       ret = _media_svc_update_item_by_path(org_stg_id, src_path, dst_stg_id, dst_stg_type, dest_path, file_name, modified_time, folder_uuid, uid);
+       SAFE_FREE(file_name);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
-               /*update db*/
-               ret = _media_svc_list_query_do(MEDIA_SVC_QUERY_MOVE_ITEM, uid);
-               media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+       media_svc_debug("Move is successful. Sending noti for this");
 
-               g_media_svc_move_item_cur_data_cnt = 0;
+       /* Get notification info */
+       media_svc_noti_item *noti_item = NULL;
+       ret = _media_svc_get_noti_info(db_handle, dst_stg_id, dest_path, MS_MEDIA_ITEM_FILE, &noti_item);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
-       } else {
-               media_svc_error("Error in media_svc_move_item");
-               SAFE_FREE(file_name);
-               return MS_MEDIA_ERR_INTERNAL;
-       }
+       /* Send notification for move */
+       _media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, src_path, media_type, noti_item->media_uuid, noti_item->mime_type);
+       _media_svc_destroy_noti_item(noti_item);
 
-       /*rename thumbnail file*/
-       if (STRING_VALID(old_thumb_path)) {
-               ret = _media_svc_rename_file(old_thumb_path, new_thumb_path);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("_media_svc_rename_file failed : %d", ret);
-       }
+       /*update folder modified_time*/
+       folder_path = g_path_get_dirname(dest_path);
+       ret = _media_svc_update_folder_modified_time_by_folder_uuid(folder_uuid, folder_path, uid);
+       SAFE_FREE(folder_path);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
        return MS_MEDIA_ERR_NONE;
 }
@@ -1099,7 +1045,7 @@ int media_svc_update_folder_time(MediaSvcHandle *handle, const char *storage_id,
        ret = _media_svc_get_folder_info_by_foldername(db_handle, storage_id, folder_path, folder_uuid, &sto_time);
        if (ret == MS_MEDIA_ERR_NONE) {
                if (sto_time != cur_time)
-                       ret = _media_svc_update_folder_modified_time_by_folder_uuid(folder_uuid, folder_path, FALSE, uid);
+                       ret = _media_svc_update_folder_modified_time_by_folder_uuid(folder_uuid, folder_path, uid);
        }
 
        return ret;
@@ -1863,7 +1809,7 @@ int media_svc_get_media_type(const char *path, int *mediatype)
        return _media_svc_get_media_type(path, mediatype);
 }
 
-int media_svc_create_thumbnail(const char *file_path, int media_type, uid_t uid, char **thumbnail_path)
+int media_svc_create_thumbnail(const char *storage_id, const char *file_path, int media_type, uid_t uid, char **thumbnail_path)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = { 0, };
@@ -1879,7 +1825,7 @@ int media_svc_create_thumbnail(const char *file_path, int media_type, uid_t uid,
                media_svc_error("Failed to create thumbnail [%d]", ret);
 
        // 3. Update creation result to media db
-       sql = sqlite3_mprintf("UPDATE %q SET thumbnail_path = '%q' WHERE path='%q';", MEDIA_SVC_DB_TABLE_MEDIA, thumb_path, file_path);
+       sql = sqlite3_mprintf("UPDATE '%q' SET thumbnail_path='%q' WHERE path='%q';", storage_id, thumb_path, file_path);
 
        ret = _media_svc_sql_query(sql, uid);
        SQLITE3_SAFE_FREE(sql);
index d82689f..5a7bc11 100755 (executable)
 
 int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid);
 int _media_svc_get_folder_id_by_foldername_with_validity(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid, int *validity);
-int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, bool stack_query, uid_t uid);
+int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, uid_t uid);
 int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid);
 int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid);
-int _media_svc_update_folder_table(const char *storage_id, uid_t uid);
 int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid);
 int _media_svc_get_folder_info_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, time_t *modified_time);
 int _media_svc_delete_invalid_folder(const char *storage_id, int storage_type, uid_t uid);
index 4e1d759..b0d60e5 100755 (executable)
@@ -41,7 +41,7 @@ int _media_svc_update_storage_item_validity(const char *storage_id, media_svc_st
 int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, uid_t uid);
 int _media_svc_update_recursive_folder_item_validity(const char *storage_id, const char *folder_path, int validity, uid_t uid);
 int _media_svc_update_item_validity(const char *storage_id, const char *path, int validity, bool stack_query, uid_t uid);
-int _media_svc_update_item_by_path(const char *src_path, media_svc_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, const char *thumb_path, bool stack_query, uid_t uid);
+int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, media_svc_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, uid_t uid);
 int _media_svc_list_query_do(media_svc_query_type_e query_type, uid_t uid);
 int _media_svc_update_thumbnail_path(const char *path, const char *thumb_path, uid_t uid);
 int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, int update_item, media_svc_noti_item **item);
index 7849384..9b40fca 100755 (executable)
@@ -152,7 +152,7 @@ gboolean _send_noti_operations(gpointer data)
 
        /* 2. media_svc_move_item */
        const char *dst_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image11.jpg");
-       ret = media_svc_move_item(g_db_handle, storage_type, path, storage_type, dst_path);
+       ret = media_svc_move_item(g_db_handle, path, dst_path);
        if (ret != MS_MEDIA_ERR_NONE) {
                media_svc_error("media_svc_move_item failed : %d", ret);
                return FALSE;