Fix bug when use fresh function 16/152216/1
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 25 Sep 2017 09:12:57 +0000 (18:12 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 25 Sep 2017 09:12:57 +0000 (18:12 +0900)
Need to consider the case of no thumbnail

Change-Id: I36012e1cbaaedceb722120e257a75f70b885ade4
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/media-svc.c

index d6fbd66..9ca0e5f 100755 (executable)
@@ -808,6 +808,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *db_handle = (sqlite3 *)handle;
        media_svc_media_type_e media_type;
+       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
 
        media_svc_retvm_if(db_handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
@@ -823,23 +824,24 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
                return ret;
 
        /* Initialize thumbnail information to remake thumbnail. */
-       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1];
        ret = _media_svc_get_thumbnail_path_by_path(db_handle, path, thumb_path);
-       if (ret != MS_MEDIA_ERR_NONE) {
+       if (ret != MS_MEDIA_ERR_NONE && ret != MS_MEDIA_ERR_DB_NO_RECORD) {
                _media_svc_destroy_content_info(&content_info);
                return ret;
        }
 
-       if (g_file_test(thumb_path, G_FILE_TEST_EXISTS)) {
-               ret = _media_svc_remove_file(thumb_path);
-               if (ret != MS_MEDIA_ERR_NONE)
-                       media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
-       }
+       if (STRING_VALID(thumb_path)) {
+               if (g_file_test(thumb_path, G_FILE_TEST_EXISTS)) {
+                       ret = _media_svc_remove_file(thumb_path);
+                       if (ret != MS_MEDIA_ERR_NONE)
+                               media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
+               }
 
-       ret = _media_svc_update_thumbnail_path(path, NULL, uid);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               _media_svc_destroy_content_info(&content_info);
-               return ret;
+               ret = _media_svc_update_thumbnail_path(path, NULL, uid);
+               if (ret != MS_MEDIA_ERR_NONE) {
+                       _media_svc_destroy_content_info(&content_info);
+                       return ret;
+               }
        }
 
        /* Get notification info */
@@ -872,7 +874,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
        /* Extracting thumbnail */
        if (content_info.thumbnail_path == NULL) {
                if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
-                       char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
+                       memset(thumb_path, 0, sizeof(thumb_path));
 
                        ret = _media_svc_request_thumbnail(content_info.path, thumb_path, sizeof(thumb_path), uid);
                        if (ret == MS_MEDIA_ERR_NONE)