summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2019-05-15 11:19:18 +0900
committerMinje ahn <minje.ahn@samsung.com>2019-05-20 23:11:01 +0000
commita37a9e6a3585626c7afe72c0ab0acd32848803f9 (patch)
treede9548de877440efcb48aa01899d4cf2d3466a08
parent9d259adae91e5b82d17d1da84cfbc3c2e0234a80 (diff)
downloadlibmedia-service-a37a9e6a3585626c7afe72c0ab0acd32848803f9.tar.gz
libmedia-service-a37a9e6a3585626c7afe72c0ab0acd32848803f9.tar.bz2
libmedia-service-a37a9e6a3585626c7afe72c0ab0acd32848803f9.zip
Modify scanner progress
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>
-rwxr-xr-xinclude/media-svc.h2
-rwxr-xr-xplugin/media-content-plugin.c12
-rwxr-xr-xsrc/common/media-svc-media.c10
-rwxr-xr-xsrc/common/media-svc.c6
-rwxr-xr-xsrc/include/common/media-svc-media.h2
5 files changed, 25 insertions, 7 deletions
diff --git a/include/media-svc.h b/include/media-svc.h
index b5c9b29..e998f3f 100755
--- a/include/media-svc.h
+++ b/include/media-svc.h
@@ -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);
diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c
index 8c701fa..0b93f17 100755
--- a/plugin/media-content-plugin.c
+++ b/plugin/media-content-plugin.c
@@ -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);
+}
diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c
index 406e895..f5bcde5 100755
--- a/src/common/media-svc-media.c
+++ b/src/common/media-svc-media.c
@@ -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;
diff --git a/src/common/media-svc.c b/src/common/media-svc.c
index c5ec64f..e521880 100755
--- a/src/common/media-svc.c
+++ b/src/common/media-svc.c
@@ -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");
diff --git a/src/include/common/media-svc-media.h b/src/include/common/media-svc-media.h
index a294234..e2db8f3 100755
--- a/src/include/common/media-svc-media.h
+++ b/src/include/common/media-svc-media.h
@@ -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);