Remove storage_id parameter 29/282829/2
authorminje.ahn <minje.ahn@samsung.com>
Wed, 12 Oct 2022 05:56:06 +0000 (14:56 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Thu, 13 Oct 2022 06:58:41 +0000 (06:58 +0000)
Removed 'storage_id' as it does not affect the query results.

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

index ca9b1c1..53c68c8 100755 (executable)
@@ -64,9 +64,9 @@ int media_svc_insert_storage(sqlite3 *handle, const char *storage_id, const char
 int media_svc_update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid);
 int media_svc_set_storage_validity(sqlite3 *handle, const char *storage_id, int validity, uid_t uid);
 int media_svc_get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid);
-int media_svc_set_folder_validity(const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid);
+int media_svc_set_folder_validity(const char *start_path, int validity, bool is_recursive, uid_t uid);
 
-int media_svc_check_folder_exist_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path);
+int media_svc_check_folder_exist_by_path(sqlite3 *handle, const char *folder_path);
 
 int media_svc_append_query(const char *query, uid_t uid);
 int media_svc_send_query(uid_t uid);
index a92043f..93075f2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
-Version:    0.4.25
+Version:    0.4.26
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0 and PD
index 4b5c6ea..7d418c1 100755 (executable)
@@ -161,7 +161,7 @@ int insert_folder(sqlite3 *handle, const char *storage_id, const char *file_path
 
 int set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
 {
-       return media_svc_set_folder_validity(storage_id, start_path, validity, is_recursive, uid);
+       return media_svc_set_folder_validity(start_path, validity, is_recursive, uid);
 }
 
 int get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *status)
@@ -196,7 +196,7 @@ int change_validity_item_batch(sqlite3 *handle, const char *storage_id, const ch
 
 int check_folder_exist(sqlite3 *handle, const char *storage_id, const char *folder_path)
 {
-       return media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
+       return media_svc_check_folder_exist_by_path(handle, folder_path);
 }
 
 int get_media_type(const char *path, int *mediatype)
index fea9da1..e414906 100755 (executable)
 #include "media-svc-util.h"
 #include "media-svc-db-utils.h"
 
-int _media_svc_get_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id)
+static int __media_svc_get_folder_id(sqlite3 *handle, const char *path, char *folder_id)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3_stmt *sql_stmt = NULL;
        char *sql = NULL;
 
-       sql = sqlite3_mprintf("SELECT folder_id FROM %q WHERE folder_path=%Q AND storage_uuid=%Q", DB_TABLE_FOLDER, path, storage_id);
+       sql = sqlite3_mprintf("SELECT folder_id FROM %q WHERE folder_path=%Q", DB_TABLE_FOLDER, path);
 
        ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
        media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_sql_prepare_to_step failed [%d]", ret);
@@ -75,17 +75,17 @@ static int __media_svc_append_folder(bool is_direct, const char *storage_id, ms_
        return ret;
 }
 
-int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, uid_t uid)
+int _media_svc_update_folder_modified_time(const char *folder_path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       int modified_time = 0;
+       int time = 0;
+       char *query = NULL;
 
-       modified_time = _media_svc_get_file_time(folder_path);
+       time = _media_svc_get_file_time(folder_path);
+       query = sqlite3_mprintf("UPDATE %q SET folder_modified_time=%d WHERE folder_path=%Q", DB_TABLE_FOLDER, time, folder_path);
 
-       char *sql = sqlite3_mprintf("UPDATE %q SET folder_modified_time=%d WHERE folder_id=%Q;", DB_TABLE_FOLDER, modified_time, folder_uuid);
-
-       ret = _media_svc_sql_query(sql, uid);
-       SQLITE3_SAFE_FREE(sql);
+       ret = _media_svc_sql_query(query, uid);
+       SQLITE3_SAFE_FREE(query);
 
        return ret;
 }
@@ -121,7 +121,7 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, bool is_dir
                        dir_path = g_strdup(path);
                }
 
-               ret = _media_svc_check_folder_by_path(handle, storage_id, dir_path);
+               ret = _media_svc_check_folder_by_path(handle, dir_path);
                if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
                        g_free(folder_uuid);
                        folder_uuid = _media_info_generate_uuid();
@@ -159,7 +159,7 @@ int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, bool is_direct,
 
        dir_path = g_path_get_dirname(path);
 
-       ret = _media_svc_get_folder_id_by_path(handle, storage_id, dir_path, folder_id);
+       ret = __media_svc_get_folder_id(handle, dir_path, folder_id);
        if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
                ret = __media_svc_get_and_append_parent_folder(handle, is_direct, storage_id, dir_path, storage_type, folder_id, uid);
 
@@ -173,26 +173,25 @@ int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const ch
        int ret = MS_MEDIA_ERR_NONE;
        char folder_id[MEDIA_SVC_UUID_SIZE + 1] = {0, };
 
-       ret = _media_svc_check_folder_by_path(handle, storage_id, path);
+       ret = _media_svc_check_folder_by_path(handle, path);
        if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
                ret = __media_svc_get_and_append_parent_folder(handle, true, storage_id, path, storage_type, folder_id, uid);
        else
-               ret = _media_svc_set_folder_validity(true, storage_id, path, 1, false, uid);
+               ret = _media_svc_set_folder_validity(true, path, 1, false, uid);
 
        return ret;
 }
 
-int _media_svc_set_folder_validity(bool is_direct, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
+int _media_svc_set_folder_validity(bool is_direct, const char *start_path, int validity, bool is_recursive, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char *sql = NULL;
 
        if (is_recursive) {
-               sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_uuid='%q' AND (folder_path LIKE '%q/%%' OR folder_path='%q');",
-                       DB_TABLE_FOLDER, validity, storage_id, start_path, start_path);
+               sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE folder_path LIKE '%q/%%' OR folder_path=%Q",
+                       DB_TABLE_FOLDER, validity, start_path, start_path);
        } else {
-               sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_uuid='%q' AND folder_path='%q';",
-                       DB_TABLE_FOLDER, validity, storage_id, start_path);
+               sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE folder_path=%Q", DB_TABLE_FOLDER, validity, start_path);
        }
 
        if (is_direct)
@@ -205,16 +204,15 @@ int _media_svc_set_folder_validity(bool is_direct, const char *storage_id, const
        return ret;
 }
 
-int _media_svc_check_folder_by_path(sqlite3 *handle, const char *storage_id, const char *path)
+int _media_svc_check_folder_by_path(sqlite3 *handle, const char *path)
 {
        int ret = MS_MEDIA_ERR_NONE;
        sqlite3_stmt *sql_stmt = NULL;
        char *sql = NULL;
 
-       media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
        media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
 
-       sql = sqlite3_mprintf("SELECT 1 FROM %q WHERE folder_path=%Q AND storage_uuid=%Q", DB_TABLE_FOLDER, path, storage_id);
+       sql = sqlite3_mprintf("SELECT 1 FROM %q WHERE folder_path=%Q", DB_TABLE_FOLDER, path);
        ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
index 2ed7b8c..2b8231e 100755 (executable)
@@ -398,7 +398,7 @@ int media_svc_move_item(sqlite3 *handle,
 
        /*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);
+       ret = _media_svc_update_folder_modified_time(folder_path, uid);
        g_free(folder_path);
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
@@ -711,14 +711,14 @@ int media_svc_insert_folder(sqlite3 *handle, const char *storage_id, ms_user_sto
        return _media_svc_get_and_append_folder_id_by_folder_path(handle, storage_id, path, storage_type, uid);
 }
 
-int media_svc_set_folder_validity(const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
+int media_svc_set_folder_validity(const char *start_path, int validity, bool is_recursive, uid_t uid)
 {
-       return _media_svc_set_folder_validity(true, storage_id, start_path, validity, is_recursive, uid);
+       return _media_svc_set_folder_validity(true, start_path, validity, is_recursive, uid);
 }
 
-int media_svc_check_folder_exist_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path)
+int media_svc_check_folder_exist_by_path(sqlite3 *handle, const char *folder_path)
 {
-       return _media_svc_check_folder_by_path(handle, storage_id, folder_path);
+       return _media_svc_check_folder_by_path(handle, folder_path);
 }
 
 int media_svc_append_query(const char *query, uid_t uid)
index 2663f6a..437b223 100755 (executable)
 #include <stdbool.h>
 #include <media-util.h>
 
-int _media_svc_get_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, char *folder_id);
-int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, uid_t uid);
+int _media_svc_update_folder_modified_time(const char *folder_path, uid_t uid);
 int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid);
 int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, uid_t uid);
-int _media_svc_set_folder_validity(bool is_direct, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid);
-int _media_svc_check_folder_by_path(sqlite3 *handle, const char *storage_id, const char *path);
+int _media_svc_set_folder_validity(bool is_direct, const char *start_path, int validity, bool is_recursive, uid_t uid);
+int _media_svc_check_folder_by_path(sqlite3 *handle, const char *path);
 
 #endif /*_MEDIA_SVC_MEDIA_FOLDER_H_*/