Remove storage type 90/304790/5
authorminje.ahn <minje.ahn@samsung.com>
Tue, 23 Jan 2024 23:53:55 +0000 (08:53 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Wed, 24 Jan 2024 07:04:56 +0000 (16:04 +0900)
Change-Id: Ic9bc9ba6ecc6ae16f4bec325e24f685e8bf64b29
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
lib/include/media-util-user.h
lib/media-util-register.c
lib/media-util-user.c
packaging/media-server.spec
src/common/include/media-common-db-svc.h
src/common/media-common-db-svc.c
src/common/media-common-utils.c
src/scanner-v2/media-scanner-extract-v2.c

index 79c30ad..df72b7a 100644 (file)
 extern "C" {
 #endif
 
-typedef enum {
-       MS_USER_STORAGE_INTERNAL = 0,   /**< The device's internal storage */
-       MS_USER_STORAGE_EXTERNAL = 1,   /**< The device's external storage */
-       MS_USER_STORAGE_EXTERNAL_USB = 2,       /**< The external USB storage (Since 2.4) */
-} ms_user_storage_type_e;
-
 int ms_user_get_internal_root_path(uid_t uid, char **path);
-int ms_user_get_storage_type(uid_t uid, const char *path, ms_user_storage_type_e *storage_type);
+bool ms_user_is_valid_path(uid_t uid, const char *path);
+bool ms_user_thumb_support(uid_t uid, const char *path);
 int ms_user_get_root_thumb_store_path(uid_t uid, char **path);
 int ms_user_get_media_db_path(uid_t uid, char **path);
 int ms_user_get_wordbook_db_path(uid_t uid, char **path);
index 69bb5a0..80ef340 100644 (file)
@@ -38,11 +38,7 @@ static GSList *req_list;
 
 static int __check_dir_path(const char *dir_path, uid_t uid)
 {
-       int ret = MS_MEDIA_ERR_NONE;
-       ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
-
-       ret = ms_user_get_storage_type(uid, dir_path, &storage_type);
-       MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
+       MSAPI_RETVM_IF(!ms_user_is_valid_path(uid, dir_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
 
        /* dir_path can be a deleted path. */
        if (g_file_test(dir_path, G_FILE_TEST_EXISTS)) {
index 1460125..4c133ee 100644 (file)
@@ -101,30 +101,41 @@ int ms_user_get_internal_root_path(uid_t uid, char **path)
        return MS_MEDIA_ERR_NONE;
 }
 
-int ms_user_get_storage_type(uid_t uid, const char *path, ms_user_storage_type_e *storage_type)
+static bool __ms_user_is_internal(uid_t uid, const char *path)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       char *internal_path = NULL;
+       g_autofree gchar *internal_path = NULL;
 
-       MSAPI_RETVM_IF(!MS_STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
+       MSAPI_RETVM_IF(!MS_STRING_VALID(path), false, "Invalid path");
 
        ret = ms_user_get_internal_root_path(uid, &internal_path);
-       MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get internal root path");
-
-       if (g_str_has_prefix(path, internal_path)) {
-               *storage_type = MS_USER_STORAGE_INTERNAL;
-       } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && g_str_has_prefix(path, MEDIA_ROOT_PATH_SDCARD)) {
-               *storage_type = MS_USER_STORAGE_EXTERNAL;
-       } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && g_str_has_prefix(path, MEDIA_ROOT_PATH_USB)) {
-               *storage_type = MS_USER_STORAGE_EXTERNAL_USB;
-       } else {
-               MSAPI_DBG_ERR("[%s][%s][%s]", MEDIA_ROOT_PATH_SDCARD, MEDIA_ROOT_PATH_USB, path);
-               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
+       MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, false, "Fail to get internal root path");
 
-       g_free(internal_path);
+       return g_str_has_prefix(path, internal_path);
+}
 
-       return ret;
+bool ms_user_is_valid_path(uid_t uid, const char *path)
+{
+       if (__ms_user_is_internal(uid, path))
+               return true;
+
+       if (MS_STRING_VALID(MEDIA_ROOT_PATH_EXTERNAL) && g_str_has_prefix(path, MEDIA_ROOT_PATH_EXTERNAL))
+               return true;
+
+       MSAPI_DBG_ERR("Invalid path[%s]", path);
+
+       return false;
+}
+
+bool ms_user_thumb_support(uid_t uid, const char *path)
+{
+       if (__ms_user_is_internal(uid, path))
+               return true;
+
+       if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && g_str_has_prefix(path, MEDIA_ROOT_PATH_SDCARD))
+               return true;
+
+       return false;
 }
 
 int ms_user_get_root_thumb_store_path(uid_t uid, char **path)
index 9dbc8ae..6731337 100644 (file)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    A server for media content management
-Version:    0.5.1
+Version:    0.5.2
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
index ca6e105..dcb4ac7 100644 (file)
@@ -67,7 +67,7 @@ int ms_set_storage_scan_status(sqlite3 *handle, char *storage_id, media_scan_sta
 int ms_genarate_uuid(char **uuid);
 int ms_scan_item_batch(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
 int ms_get_extract_list(sqlite3 *handle, const char *storage_id, int scan_type, const char* path, int is_end, void *array);
-int ms_update_one_extract_item(sqlite3 *handle, const char *storage_id, int storage_type, void *data);
+int ms_update_one_extract_item(sqlite3 *handle, const char *storage_id, void *data);
 int ms_delete_invalid_items_in_folder(sqlite3 *handle, const char *storage_id, const char *path, bool is_recursive, uid_t uid);
 int ms_delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid);
 int ms_get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *scan_status);
index d1b0588..716857d 100644 (file)
@@ -37,15 +37,15 @@ typedef int (*INSERT_ITEM_BEGIN)(bool, int);
 typedef int (*INSERT_ITEM_END)(uid_t);
 
 typedef int (*SEND_DIR_UPDATE_NOTI)(const char *, const char *, int, int);
-typedef int (*INSERT_ITEM)(sqlite3 *, const char *, const char *, int, uid_t);
+typedef int (*INSERT_ITEM)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*SET_ITEM_VALIDITY)(const char *, const char *, int, int, uid_t);
 typedef int (*GET_STORAGE_ID)(sqlite3 *, const char *, char *, uid_t uid);
-typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, int, uid_t);
+typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*SET_FOLDER_VALIDITY)(sqlite3 *, const char *, const char *, int, bool, uid_t);
 
 typedef int (*CHECK_DB)(sqlite3 *, uid_t);
 typedef int (*CHECK_STORAGE)(sqlite3 *, const char *, char **, int *, uid_t);
-typedef int (*INSERT_STORAGE)(sqlite3 *, const char *, int, const char *, uid_t);
+typedef int (*INSERT_STORAGE)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*UPDATE_STORAGE)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*SET_STORAGE_VALIDITY)(sqlite3 *, const char *, int, uid_t uid);
 typedef int (*SET_ALL_STORAGE_VALIDITY)(sqlite3 *, int, uid_t);
@@ -58,9 +58,9 @@ typedef int (*CLEANUP_DB)(sqlite3 *, uid_t);
 typedef int (*UPDATE_FOLDER_TIME)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*GET_UUID)(char **);
 typedef int (*SET_STORAGE_SCAN_STATUS)(sqlite3 *, const char *, int, uid_t);
-typedef int (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, int, uid_t);
+typedef int (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*GET_EXTRACT_LIST)(sqlite3 *, const char*, int, const char *, int, void*);
-typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3 *, const char *, int, void *);
+typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3 *, const char *, void *);
 typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(sqlite3 *, const char *, const char *, bool, uid_t);
 typedef int (*DELETE_INVALID_FOLDER_BY_PATH)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*GET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int *);
@@ -310,14 +310,10 @@ int ms_validity_change_all_items(sqlite3 *handle, const char *storage_id, bool v
 int ms_insert_item_batch(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       ms_user_storage_type_e storage_type = -1;
 
        MS_DBG_FENTER();
 
-       ret = ms_user_get_storage_type(uid, path, &storage_type);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get storage type");
-
-       ret = ((INSERT_ITEM)func_array[eINSERT_BATCH])(handle, storage_id, path, storage_type, uid);
+       ret = ((INSERT_ITEM)func_array[eINSERT_BATCH])(handle, storage_id, path, uid);
        MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_ITEM failed [%d]", ret);
 
        return ret;
@@ -433,12 +429,8 @@ int ms_get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t
 int ms_insert_folder(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       ms_user_storage_type_e storage_type;
-
-       ret = ms_user_get_storage_type(uid, path, &storage_type);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get storage type");
 
-       ret = ((INSERT_FOLDER)func_array[eINSERT_FOLDER])(handle, storage_id, path, storage_type, uid);
+       ret = ((INSERT_FOLDER)func_array[eINSERT_FOLDER])(handle, storage_id, path, uid);
        MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_FOLDER failed [%d]", ret);
 
        return ret;
@@ -504,14 +496,10 @@ int ms_check_storage(sqlite3 *handle, const char *storage_id, char **storage_pat
 int ms_insert_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       ms_user_storage_type_e storage_type;
 
        MS_DBG_FENTER();
 
-       ret = ms_user_get_storage_type(uid, storage_path, &storage_type);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get storage type");
-
-       ret = ((INSERT_STORAGE)func_array[eINSERT_STORAGE])(handle, storage_id, storage_type, storage_path, uid);
+       ret = ((INSERT_STORAGE)func_array[eINSERT_STORAGE])(handle, storage_id, storage_path, uid);
        MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_STORAGE failed [%d]", ret);
 
        MS_DBG_FLEAVE();
@@ -705,14 +693,10 @@ int ms_genarate_uuid(char **uuid)
 int ms_scan_item_batch(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       ms_user_storage_type_e storage_type;
 
        MS_DBG_FENTER();
 
-       ret = ms_user_get_storage_type(uid, path, &storage_type);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get storage type");
-
-       ret = ((INSERT_ITEM_SCAN)func_array[eINSERT_SCAN])(handle, storage_id, path, storage_type, uid);
+       ret = ((INSERT_ITEM_SCAN)func_array[eINSERT_SCAN])(handle, storage_id, path, uid);
        MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_ITEM_SCAN failed [%d]", ret);
 
        return ret;
@@ -728,11 +712,11 @@ int ms_get_extract_list(sqlite3 *handle, const char* storage_id, int scan_type,
        return ret;
 }
 
-int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, int storage_type, void *data)
+int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, void *data)
 {
        int ret = MS_MEDIA_ERR_NONE;
 
-       ret = ((UPDATE_ONE_EXTRACT_ITEM)func_array[eUPDATE_ONE_EXTRACT_ITEM])(handle, storage_id, storage_type, data);
+       ret = ((UPDATE_ONE_EXTRACT_ITEM)func_array[eUPDATE_ONE_EXTRACT_ITEM])(handle, storage_id, data);
        MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "UPDATE_ONE_EXTRACT_ITEM failed [%d]", ret);
 
        return ret;
index ed4ce53..9ca042c 100644 (file)
@@ -29,22 +29,7 @@ int ms_verify_all_parent_dirs(const char *full_path, uid_t uid)
        int ret = MS_MEDIA_ERR_NONE;
        char *dir_path = NULL;
        char *next = NULL;
-       int next_pos = 0;
-       ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
-
-       ret = ms_user_get_storage_type(uid, full_path, &storage_type);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Invalid path");
-
-       if (storage_type == MS_USER_STORAGE_INTERNAL) {
-               ret = ms_user_get_internal_root_path(uid, &dir_path);
-               MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_internal_root_path() fail");
-
-               next_pos = strlen(dir_path);
-               g_free(dir_path);
-               dir_path = NULL;
-       } else {
-               next_pos = strlen(MEDIA_ROOT_PATH_USB) + 1;
-       }
+       int next_pos = 1;
 
        while ((next = strstr(full_path + next_pos, "/"))) {
                next_pos = (next - full_path);
index 8172709..6ad5368 100644 (file)
@@ -95,7 +95,7 @@ void msc_deinit_extract_thread(void)
        g_cond_clear(&extract_data_cond);
 }
 
-static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, int storage_type, const char *path, int scan_type, int pid, bool is_end)
+static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, const char *path, int scan_type, int pid, bool is_end)
 {
        MS_DBG_WARN("begin of __msc_folder_bulk_extract");
        int ret = MS_MEDIA_ERR_NONE;
@@ -120,7 +120,7 @@ static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, in
                g_array_remove_index(data_array, 0);
 
                g_mutex_lock(&decode_mutex);
-               ms_update_one_extract_item(handle, storage_id, storage_type, db_data);
+               ms_update_one_extract_item(handle, storage_id, db_data);
                g_mutex_unlock(&decode_mutex);
 
                if (db_data) {
@@ -158,7 +158,6 @@ gpointer msc_folder_extract_thread(gpointer data)
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *handle = NULL;
        int end_flag = NORMAL_EVENT;
-       ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
 
        while (1) {
                extract_data = g_async_queue_pop(folder_extract_queue);
@@ -202,12 +201,6 @@ gpointer msc_folder_extract_thread(gpointer data)
                }
                end_flag = extract_data->result ? LAST_EVENT : NORMAL_EVENT;
 
-               ret = ms_user_get_storage_type(extract_data->uid, extract_data->msg, &storage_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       MS_DBG_ERR("ms_user_get_storage_type failed");
-                       goto NEXT;
-               }
-
                ret = __msc_check_extract_stop_status(extract_data->msg_type, extract_data->msg, extract_data->pid);
                if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
                        MS_DBG_ERR("MS_MEDIA_ERR_SCANNER_FORCE_STOP");
@@ -223,7 +216,7 @@ gpointer msc_folder_extract_thread(gpointer data)
                        goto NEXT;
                }
 
-               ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, extract_data->msg, extract_data->msg_type, extract_data->pid, end_flag);
+               ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, extract_data->msg, extract_data->msg_type, extract_data->pid, end_flag);
 
 NEXT:
                g_directory_extract_processing = false;
@@ -281,7 +274,6 @@ gpointer msc_storage_extract_thread(gpointer data)
        ms_comm_msg_s *extract_data = NULL;
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3 *handle = NULL;
-       ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
        int end_flag = NORMAL_EVENT;
 
        resource_pid_t stResource = {};
@@ -336,12 +328,7 @@ gpointer msc_storage_extract_thread(gpointer data)
                        goto NEXT;
                }
 
-               ret = ms_user_get_storage_type(extract_data->uid, extract_data->msg, &storage_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       MS_DBG_ERR("ms_user_get_storage_type failed");
-                       goto NEXT;
-               }
-               if (storage_type == MS_USER_STORAGE_EXTERNAL_USB) {
+               if (MEDIA_ROOT_PATH_EXTERNAL && g_str_has_prefix(extract_data->msg, MEDIA_ROOT_PATH_EXTERNAL)) {
                        if (!ms_storage_mount_status(extract_data->msg)) {
                                MS_DBG_ERR("%s is unmounted", extract_data->msg);
                                ret = MS_MEDIA_ERR_USB_UNMOUNTED;
@@ -360,7 +347,7 @@ gpointer msc_storage_extract_thread(gpointer data)
                }
 
                /*extract meta*/
-               ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, extract_data->msg, extract_data->msg_type, extract_data->pid, end_flag);
+               ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, extract_data->msg, extract_data->msg_type, extract_data->pid, end_flag);
                MS_DBG_WARN("extract PAUSE");
                __msc_pause_extract();
                MS_DBG_WARN("extract RESUME");