Fixed issue regarding not able to check for the existence of the sticker 80/246380/2
authorInHong Han <inhong1.han@samsung.com>
Thu, 29 Oct 2020 01:28:04 +0000 (10:28 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 29 Oct 2020 02:00:26 +0000 (11:00 +0900)
Change-Id: Id684199f552d04e6d3c865eeafe5f49089d533fd

client/sticker_defs.h
provider/sticker_provider.c
server/stickerd_data_manager.c

index 69167eca9ce7df64c35502dded67ab8ef018338d..f00e7daf0a2df0ec592a40382605e98307bc1ef5 100644 (file)
@@ -49,6 +49,7 @@ extern "C" {
       }  \
     }  \
   } while (0)
+#define STICKER_DIRECTORY "/opt/usr/share/sticker-data"
 
 typedef enum {
     STICKER_CLIENT_LIB_NONE,
index 82e32c8315f9cf9ecf3811e33d010b8717c0528d..8b5ef3223f964f00f5fc34d6042cb06dcdffc374 100644 (file)
@@ -136,26 +136,43 @@ EXPORT_API int sticker_provider_insert_data(sticker_provider_h provider_handle,
     if (!provider_handle || !data_handle || (data_handle->sticker_info_id > 0) || !data_handle->uri)
         return STICKER_ERROR_INVALID_PARAMETER;
 
-    ret = sticker_dbus_check_file_exists(provider_handle->gdbus_connection, data_handle->uri, &is_exist);
+    int len = strlen(STICKER_DIRECTORY) + strlen(data_handle->app_id) + strlen(data_handle->uri) + 3;
+    char *new_path = (char *)calloc(len, sizeof(char));
+
+    if (data_handle->uri[0] == '/')
+        snprintf(new_path, len, "%s/%s%s",STICKER_DIRECTORY, data_handle->app_id, data_handle->uri);
+    else
+        snprintf(new_path, len, "%s/%s/%s",STICKER_DIRECTORY, data_handle->app_id, data_handle->uri);
+
+    ret = sticker_dbus_check_file_exists(provider_handle->gdbus_connection, new_path, &is_exist);
     if (ret != STICKER_ERROR_NONE) {
         LOGE("Failed to check file exists : %d", ret);
-        return STICKER_ERROR_OPERATION_FAILED;
+        ret = STICKER_ERROR_OPERATION_FAILED;
+        goto cleanup;
     }
 
     if (is_exist) {
         LOGE("Sticker already exists");
-        return STICKER_ERROR_FILE_EXISTS;
+        ret = STICKER_ERROR_FILE_EXISTS;
+        goto cleanup;
     }
 
     ret = sticker_dbus_insert_sticker_info(provider_handle->gdbus_connection, data_handle);
     if (ret != STICKER_ERROR_NONE) {
         LOGE("Failed to insert sticker information : %d", ret);
         if (ret == STICKER_CLIENT_ERROR_NO_SUCH_FILE)
-            return STICKER_ERROR_NO_SUCH_FILE;
+            ret = STICKER_ERROR_NO_SUCH_FILE;
         else
-            return STICKER_ERROR_OPERATION_FAILED;
+            ret = STICKER_ERROR_OPERATION_FAILED;
     }
-    return STICKER_ERROR_NONE;
+
+cleanup:
+    if (new_path) {
+        free(new_path);
+        new_path = NULL;
+    }
+
+    return ret;
 }
 
 EXPORT_API int sticker_provider_insert_data_by_json_file(sticker_provider_h provider_handle, const char *json_path, sticker_provider_insert_finished_cb callback, void *user_data)
index 1be9971c25ac258881d981e7cc07409638cc1051..c9b8f8bacc7d67645013b8466dae7308b5c87dd8 100644 (file)
@@ -39,7 +39,6 @@
 #endif
 #define LOG_TAG "STICKERD_DATA_MANAGER"
 
-#define STICKER_DIRECTORY "/opt/usr/share/sticker-data"
 #define MAX_ERROR_BUFFER  256
 
 static GHashTable *_monitoring_hash = NULL;