Fix issue that does not create thumbnail before OOBE 07/229507/2
authorInHong Han <inhong1.han@samsung.com>
Wed, 1 Apr 2020 10:44:25 +0000 (19:44 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 1 Apr 2020 10:54:21 +0000 (19:54 +0900)
Change-Id: Icd2d94dbf8ad1cb2db5511668df2020c57dca048

receiver/src/ft.cpp

index 2107d32..bd8ae56 100644 (file)
@@ -310,6 +310,27 @@ void accept_file()
     file_on_progress = TRUE;
 }
 
+static int _create_thumbnail_directory()
+{
+    char thumb_path[PATH_MAX];
+    char *data_path = NULL;
+    data_path = app_get_shared_data_path();
+    sprintf(thumb_path, "%s/thumbnail", data_path);
+
+    if (data_path)
+        free(data_path);
+
+    if (access(thumb_path, F_OK) == 0)
+        return 0;
+
+    if (mkdir(thumb_path, 0755) == -1) {
+        LOGE("directory create error");
+        return -1;
+    }
+
+    return 0;
+}
+
 bool request_sticker_data(const char *mode, const char *category, const char *type)
 {
     bool result = false;
@@ -334,6 +355,9 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty
         return false;
     }
 
+    if (_create_thumbnail_directory() != 0)
+        LOGE("Failed to create thumbnail directory");
+
     json_object_set_string_member(j_object, "msgId", STICKER_SYNC_START_REQ);
     json_object_set_int_member(j_object, "tID", ++t_id);
     json_object_set_string_member(j_object, "mode", mode);
@@ -358,19 +382,6 @@ bool request_sticker_data(const char *mode, const char *category, const char *ty
     return result;
 }
 
-static int _create_directory(const char *path)
-{
-    if (access(path, F_OK) == 0)
-        return 0;
-
-    if (mkdir(path, 0755) == -1) {
-        LOGE("directory create error");
-        return -1;
-    }
-
-    return 0;
-}
-
 void request_sticker_feature()
 {
     JsonObject *j_object = NULL;
@@ -398,12 +409,7 @@ void request_sticker_feature()
 
     json_object_unref(j_object);
 
-    char thumb_path[PATH_MAX];
-    char *data_path = NULL;
-    data_path = app_get_shared_data_path();
-    sprintf(thumb_path, "%s/thumbnail", data_path);
-
-    if (_create_directory(thumb_path) != 0)
+    if (_create_thumbnail_directory() != 0)
         LOGE("Failed to create thumbnail directory");
 }