Modify scanner progress 76/206176/5
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 15 May 2019 02:19:18 +0000 (11:19 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Mon, 20 May 2019 23:11:01 +0000 (23:11 +0000)
If the modified time of the database and the file system are different,
use UPDATE instead of DELETE/INSERT.

Change-Id: I7cae8da1e5091c7d547125c768cc714f75ee2f1c
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-svc.h
plugin/media-content-plugin.c
src/common/media-svc-media.c
src/common/media-svc.c
src/include/common/media-svc-media.h

index b5c9b29..e998f3f 100755 (executable)
@@ -56,7 +56,7 @@ int media_svc_set_item_validity_begin(int data_cnt);
 int media_svc_set_item_validity_end(uid_t uid);
 int media_svc_set_item_validity(const char *storage_id, const char *path, int validity, uid_t uid);
 int media_svc_delete_item_by_path(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, uid_t uid);
-int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
+int media_svc_refresh_item(sqlite3 *handle, bool is_direct, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
 int media_svc_send_dir_update_noti(const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid);
 int media_svc_check_db_upgrade(sqlite3 *handle, int user_version, uid_t uid);
 int media_svc_publish_noti(media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type);
index 8c701fa..0b93f17 100755 (executable)
@@ -245,3 +245,15 @@ int get_media_type(const char *path, int *mediatype)
 {
        return media_svc_get_media_type(path, mediatype);
 }
+
+int refresh_item(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_USER_STORAGE_INTERNAL;
+
+       ret = ms_user_get_storage_type(uid, path, &storage_type);
+       if (ret != MS_MEDIA_ERR_NONE)
+               return ret;
+
+       return media_svc_refresh_item(handle, true, storage_id, storage_type, path, uid);
+}
index 406e895..f5bcde5 100755 (executable)
@@ -290,7 +290,7 @@ int _media_svc_update_meta_with_data(media_svc_content_info_s *content_info)
        return ret;
 }
 
-int _media_svc_update_item_with_data(const char *storage_id, media_svc_content_info_s *content_info, uid_t uid)
+int _media_svc_update_item_with_data(bool is_direct, const char *storage_id, media_svc_content_info_s *content_info, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
 
@@ -359,7 +359,13 @@ int _media_svc_update_item_with_data(const char *storage_id, media_svc_content_i
                                content_info->path
                                );
 
-       ret = _media_svc_sql_query(sql, uid);
+       /* Scanner use only batch insert */
+       if (is_direct) {
+               media_svc_sec_debug("Query [%s]", sql);
+               _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
+       } else {
+               ret = _media_svc_sql_query(sql, uid);
+       }
        SQLITE3_SAFE_FREE(sql);
 
        return ret;
index c5ec64f..e521880 100755 (executable)
@@ -571,7 +571,7 @@ int media_svc_delete_item_by_path(sqlite3 *handle, bool is_direct, const char *s
        return MS_MEDIA_ERR_NONE;
 }
 
-int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
+int media_svc_refresh_item(sqlite3 *handle, bool is_direct, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
@@ -628,7 +628,7 @@ int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_stor
        else if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
                ret = _media_svc_extract_image_metadata(&content_info);
        else
-               ret = _media_svc_extract_media_metadata(handle, false, &content_info, uid);
+               ret = _media_svc_extract_media_metadata(handle, is_direct, &content_info, uid);
 
        if (ret != MS_MEDIA_ERR_NONE) {
                _media_svc_destroy_noti_item(noti_item);
@@ -647,7 +647,7 @@ int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_stor
                }
        }
 
-       ret = _media_svc_update_item_with_data(storage_id, &content_info, uid);
+       ret = _media_svc_update_item_with_data(is_direct, storage_id, &content_info, uid);
 
        if (ret == MS_MEDIA_ERR_NONE) {
                media_svc_debug("Update is successful. Sending noti for this");
index a294234..e2db8f3 100755 (executable)
@@ -31,7 +31,7 @@
 int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count);
 int _media_svc_get_modified_time(sqlite3 *handle, const char *storage_id, const char *path, int *modified_time);
 int _media_svc_insert_item_with_data(sqlite3 *handle, bool is_direct, const char *storage_id, media_svc_content_info_s *content_info, bool stack_query, uid_t uid);
-int _media_svc_update_item_with_data(const char *storage_id, media_svc_content_info_s *content_info, uid_t uid);
+int _media_svc_update_item_with_data(bool is_direct, const char *storage_id, media_svc_content_info_s *content_info, uid_t uid);
 int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, char *thumbnail_path);
 int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *storage_id, const char *path, int *media_type);
 int _media_svc_delete_item_by_path(bool is_direct, const char *storage_id, const char *path, bool stack_query, uid_t uid);