summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinclude/media-svc.h2
-rwxr-xr-xplugin/media-content-plugin.c2
-rwxr-xr-xsrc/common/media-svc-album.c8
-rwxr-xr-xsrc/common/media-svc-db-utils.c90
-rwxr-xr-xsrc/common/media-svc-media-folder.c59
-rwxr-xr-xsrc/common/media-svc-media.c67
-rwxr-xr-xsrc/common/media-svc-storage.c14
-rwxr-xr-xsrc/common/media-svc-util.c6
-rwxr-xr-xsrc/common/media-svc.c30
-rwxr-xr-xsrc/include/common/media-svc-album.h3
-rwxr-xr-xsrc/include/common/media-svc-db-utils.h2
-rwxr-xr-xsrc/include/common/media-svc-media-folder.h6
-rwxr-xr-xsrc/include/common/media-svc-media.h4
-rwxr-xr-xsrc/include/common/media-svc-util.h2
14 files changed, 194 insertions, 101 deletions
diff --git a/include/media-svc.h b/include/media-svc.h
index 2aba4a8..3a930cb 100755
--- a/include/media-svc.h
+++ b/include/media-svc.h
@@ -48,7 +48,7 @@ int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_
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, const char *storage_id, const char *path, 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_send_dir_update_noti(sqlite3 *handle, const char *storage_id, 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);
diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c
index aa5a420..b1f890b 100755
--- a/plugin/media-content-plugin.c
+++ b/plugin/media-content-plugin.c
@@ -63,7 +63,7 @@ int set_item_validity(const char *storage_id, const char *file_path, int storage
int delete_item(sqlite3 *handle, const char *storage_id, const char *file_path, uid_t uid)
{
- return media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
+ return media_svc_delete_item_by_path(handle, true, storage_id, file_path, uid);
}
int send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid)
diff --git a/src/common/media-svc-album.c b/src/common/media-svc-album.c
index 383dd3e..e45ddfc 100755
--- a/src/common/media-svc-album.c
+++ b/src/common/media-svc-album.c
@@ -57,12 +57,16 @@ int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *arti
return ret;
}
-int _media_svc_append_album(sqlite3 *handle, const char *album, const char *artist, const char *album_art, int *album_id, uid_t uid)
+int _media_svc_append_album(sqlite3 *handle, bool is_direct, const char *album, const char *artist, const char *album_art, int *album_id, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *sql = sqlite3_mprintf("INSERT INTO %s (name, artist, album_art) values (%Q, %Q, %Q);", MEDIA_SVC_DB_TABLE_ALBUM, album, artist, album_art);
- ret = _media_svc_sql_query(sql, uid);
+ if (is_direct)
+ ret = _media_svc_sql_query_direct(sql, uid);
+ else
+ ret = _media_svc_sql_query(sql, uid);
+
SQLITE3_SAFE_FREE(sql);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c
index adde488..f90825f 100755
--- a/src/common/media-svc-db-utils.c
+++ b/src/common/media-svc-db-utils.c
@@ -32,6 +32,7 @@
static int __media_svc_db_upgrade(sqlite3 *db_handle, int cur_version, uid_t uid);
static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid);
+static int __media_svc_query_direct(sqlite3 *handle, const char *query, uid_t uid);
static GHashTable *table;
@@ -1546,11 +1547,18 @@ ERROR:
int _media_svc_sql_query(const char *sql_str, uid_t uid)
{
- int ret = MS_MEDIA_ERR_NONE;
+ return media_db_request_update_db(sql_str, uid);
+}
- media_svc_sec_debug("[SQL query] : %s", sql_str);
+int _media_svc_sql_query_direct(const char *sql_str, uid_t uid)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ sqlite3 *handle = NULL;
- ret = media_db_request_update_db(sql_str, uid);
+ ret = media_db_connect(&handle, uid, true);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "DB connection failed");
+ ret = __media_svc_query_direct(handle, sql_str, uid);
+ media_db_disconnect(handle);
return ret;
}
@@ -1585,7 +1593,7 @@ int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- media_svc_sec_debug("[SQL query] : %s", sql_str);
+ media_svc_sec_debug("Query[%s]", sql_str);
err = sqlite3_prepare_v2(handle, sql_str, -1, stmt, NULL);
sqlite3_free((char *)sql_str);
@@ -1602,7 +1610,7 @@ int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3
err = sqlite3_step(*stmt);
if (err != SQLITE_ROW) {
- media_svc_error("[No-Error] Item not found. end of row [%s]", sqlite3_errmsg(handle));
+ media_svc_debug("No record");
SQLITE3_FINALIZE(*stmt);
return MS_MEDIA_ERR_DB_NO_RECORD;
}
@@ -1616,7 +1624,7 @@ int _media_svc_sql_prepare_to_step_simple(sqlite3 *handle, const char *sql_str,
media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "handle is NULL");
- media_svc_sec_debug("[SQL query] : %s", sql_str);
+ media_svc_sec_debug("Query[%s]", sql_str);
if (!STRING_VALID(sql_str)) {
media_svc_error("invalid query");
@@ -1723,6 +1731,75 @@ int _media_svc_sql_query_list(GList **query_list, uid_t uid)
}
+#define MAX_RETRY 9
+#define SLEEP_TIME 1000 * 1000
+static int __media_svc_query_direct(sqlite3 *handle, const char *query, uid_t uid)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ char *zErrMsg = NULL;
+ int retry_count = 0;
+
+EXEC_RETRY:
+ ret = sqlite3_exec(handle, query, NULL, NULL, &zErrMsg);
+ if (SQLITE_OK != ret) {
+ media_svc_sec_error("Error[%s],Query[%s]", zErrMsg, query);
+ SQLITE3_SAFE_FREE(zErrMsg);
+ if (ret == SQLITE_BUSY) {
+ ret = MS_MEDIA_ERR_DB_BUSY_FAIL;
+ } else if (ret == SQLITE_CONSTRAINT) {
+ ret = MS_MEDIA_ERR_DB_CONSTRAINT_FAIL;
+ } else if (ret == SQLITE_FULL) {
+ ret = MS_MEDIA_ERR_DB_FULL_FAIL;
+ } else if (ret == SQLITE_LOCKED) {
+ if (retry_count < MAX_RETRY) {
+ media_svc_error("Locked retry[%d]", retry_count);
+ retry_count++;
+ usleep(SLEEP_TIME);
+ goto EXEC_RETRY;
+ }
+ ret = MS_MEDIA_ERR_DB_UPDATE_FAIL;
+ } else {
+ ret = MS_MEDIA_ERR_DB_UPDATE_FAIL;
+ }
+ }
+
+ return ret;
+}
+
+int _media_svc_sql_query_list_direct(GList **query_list, uid_t uid)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ int idx = 0;
+ int length = g_list_length(*query_list);
+ char *sql = NULL;
+ sqlite3 *handle = NULL;
+
+ media_svc_debug("query list length[%d]", length);
+ if (length == 0)
+ goto ZERO_LEN;
+
+ ret = media_db_connect(&handle, uid, true);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "DB connection failed");
+
+ for (idx = 0; idx < length; idx++) {
+ sql = (char *)g_list_nth_data(*query_list, idx);
+ if (STRING_VALID(sql)) {
+ ret = __media_svc_query_direct(handle, sql, uid);
+ if (ret != MS_MEDIA_ERR_NONE)
+ media_svc_debug("_media_svc_query_direct failed[%s]", sql);
+
+ SQLITE3_SAFE_FREE(sql);
+ }
+ }
+
+ media_db_disconnect(handle);
+
+ZERO_LEN:
+ _media_svc_sql_query_release(query_list);
+
+ return MS_MEDIA_ERR_NONE;
+}
+
void _media_svc_sql_query_add(GList **query_list, char **query)
{
*query_list = g_list_append(*query_list, *query);
@@ -1731,7 +1808,6 @@ void _media_svc_sql_query_add(GList **query_list, char **query)
void _media_svc_sql_query_release(GList **query_list)
{
if (*query_list) {
- media_svc_debug("_svc_sql_query_release");
g_list_free(*query_list);
*query_list = NULL;
}
diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c
index f70f3eb..46f3a93 100755
--- a/src/common/media-svc-media-folder.c
+++ b/src/common/media-svc-media-folder.c
@@ -40,7 +40,7 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
- media_svc_debug("there is no folder.");
+ media_svc_debug("No record");
else
media_svc_error("error when _media_svc_get_folder_id_by_foldername. err = [%d]", ret);
@@ -80,7 +80,7 @@ int _media_svc_get_folder_id_by_foldername_with_validity(sqlite3 *handle, const
return ret;
}
-static int __media_svc_append_folder(const char *storage_id, ms_user_storage_type_e storage_type,
+static int __media_svc_append_folder(bool is_direct, const char *storage_id, ms_user_storage_type_e storage_type,
const char *folder_id, const char *folder_path, bool stack_query, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
@@ -95,12 +95,15 @@ static int __media_svc_append_folder(const char *storage_id, ms_user_storage_typ
if (_media_svc_check_pinyin_support())
_media_svc_get_pinyin_str(folder_name, &folder_name_pinyin);
/* Sometime SQLITE3 returns NO_RECORD, so need to consider conflict case.. */
- media_svc_debug("UNIQUE:path[%s], storage_uuid[%s]", folder_path, storage_id);
char *sql = sqlite3_mprintf("INSERT OR IGNORE INTO %q (folder_id, folder_path, folder_name, storage_uuid, folder_storage_type, folder_modified_time, folder_name_pinyin) values (%Q, %Q, %Q, %Q, '%d', '%d', %Q); ",
MEDIA_SVC_DB_TABLE_FOLDER, folder_id, folder_path, folder_name, storage_id, storage_type, folder_modified_date, folder_name_pinyin);
if (!stack_query) {
- ret = _media_svc_sql_query(sql, uid);
+ if (is_direct)
+ ret = _media_svc_sql_query_direct(sql, uid);
+ else
+ ret = _media_svc_sql_query(sql, uid);
+
SQLITE3_SAFE_FREE(sql);
} else {
_media_svc_sql_query_add(&g_media_svc_insert_folder_query_list, &sql);
@@ -127,7 +130,7 @@ int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uui
return ret;
}
-static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid)
+static int __media_svc_get_and_append_parent_folder(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 ret = MS_MEDIA_ERR_NONE;
unsigned int next_pos = 0;
@@ -169,7 +172,7 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char
} else {
dir_path = strndup(path, strlen(path));
folder_search_end = TRUE;
- media_svc_error("[No-Error] End Path [%s]", dir_path);
+ media_svc_sec_debug("End Path[%s]", dir_path);
}
if (STRING_VALID(MEDIA_ROOT_PATH_EXTERNAL) && (g_strcmp0(dir_path, MEDIA_ROOT_PATH_EXTERNAL) == 0)) {
@@ -187,13 +190,11 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char
return MS_MEDIA_ERR_INTERNAL;
}
- ret = __media_svc_append_folder(storage_id, storage_type, folder_uuid, dir_path, FALSE, uid);
+ ret = __media_svc_append_folder(is_direct, storage_id, storage_type, folder_uuid, dir_path, FALSE, uid);
if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("__media_svc_append_folder is failed");
- media_svc_error("[No-Error] New Appended folder path [%s], folder_uuid [%s]", dir_path, folder_uuid);
- } else {
- media_svc_error("EXIST dir path : %s", dir_path);
+ media_svc_sec_debug("Append new folder path[%s] uuid[%s]", dir_path, folder_uuid);
}
SAFE_FREE(dir_path);
@@ -209,7 +210,7 @@ static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char
return MS_MEDIA_ERR_NONE;
}
-static int __media_svc_update_parent_folder_validity(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
+static int __media_svc_update_parent_folder_validity(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
unsigned int next_pos = 0;
@@ -248,7 +249,7 @@ static int __media_svc_update_parent_folder_validity(sqlite3 *handle, const char
} else {
dir_path = strndup(path, strlen(path));
folder_search_end = TRUE;
- media_svc_error("[No-Error] End Path [%s]", dir_path);
+ media_svc_sec_debug("End Path [%s]", dir_path);
}
if (STRING_VALID(MEDIA_ROOT_PATH_EXTERNAL) && (g_strcmp0(dir_path, MEDIA_ROOT_PATH_EXTERNAL) == 0)) {
@@ -257,7 +258,7 @@ static int __media_svc_update_parent_folder_validity(sqlite3 *handle, const char
continue;
}
- ret = _media_svc_set_folder_validity(handle, storage_id, dir_path, 1, false, uid);
+ ret = _media_svc_set_folder_validity(handle, is_direct, storage_id, dir_path, 1, false, uid);
SAFE_FREE(dir_path);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to set folder validity");
}
@@ -265,7 +266,7 @@ static int __media_svc_update_parent_folder_validity(sqlite3 *handle, const char
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_get_and_append_folder(sqlite3 *handle, 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(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 ret = MS_MEDIA_ERR_NONE;
int validity = -1;
@@ -273,21 +274,21 @@ int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, co
ret = _media_svc_get_folder_id_by_foldername_with_validity(handle, storage_id, path, folder_id, uid, &validity);
if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
- ret = __media_svc_get_and_append_parent_folder(handle, storage_id, path, storage_type, folder_id, uid);
+ ret = __media_svc_get_and_append_parent_folder(handle, is_direct, storage_id, path, storage_type, folder_id, uid);
else if (ret == MS_MEDIA_ERR_NONE && validity == 0)
- ret = __media_svc_update_parent_folder_validity(handle, storage_id, path, uid);
+ ret = __media_svc_update_parent_folder_validity(handle, is_direct, storage_id, path, uid);
return ret;
}
-int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, 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_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)
{
char *dir_path = NULL;
int ret = MS_MEDIA_ERR_NONE;
dir_path = g_path_get_dirname(path);
- ret = _media_svc_get_and_append_folder(handle, storage_id, dir_path, storage_type, folder_id, uid);
+ ret = _media_svc_get_and_append_folder(handle, is_direct, storage_id, dir_path, storage_type, folder_id, uid);
SAFE_FREE(dir_path);
@@ -308,11 +309,11 @@ int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const ch
ret = _media_svc_get_folder_id_by_foldername(handle, storage_id, path_name, folder_id, uid);
if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- ret = __media_svc_get_and_append_parent_folder(handle, storage_id, path_name, storage_type, folder_id, uid);
+ ret = __media_svc_get_and_append_parent_folder(handle, true, storage_id, path_name, storage_type, folder_id, uid);
} else {
sql = sqlite3_mprintf("UPDATE %q SET validity=1 WHERE storage_uuid = '%q' AND folder_path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, path);
if (!stack_query) {
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
} else {
_media_svc_sql_query_add(&g_media_svc_insert_folder_query_list, &sql);
@@ -324,25 +325,23 @@ int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const ch
return ret;
}
-int _media_svc_set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
+int _media_svc_set_folder_validity(sqlite3 *handle, bool is_direct, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *sql = NULL;
- char start_path_id[MEDIA_SVC_UUID_SIZE+1] = {0,};
if (is_recursive) {
- ret = _media_svc_get_folder_id_by_foldername(handle, storage_id, start_path, start_path_id, uid);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_get_folder_id_by_foldername fail");
- media_svc_retvm_if(!STRING_VALID(start_path_id), MS_MEDIA_ERR_INVALID_PARAMETER, "start_path_id is NULL");
-
- sql = sqlite3_mprintf("UPDATE %q SET validity = %d WHERE storage_uuid = '%q' AND (folder_path LIKE '%q/%%' OR folder_id='%q');",
- MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path, start_path_id);
+ sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_uuid='%q' AND (folder_path LIKE '%q/%%' OR folder_path='%q');",
+ MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path, start_path);
} else {
- sql = sqlite3_mprintf("UPDATE %q SET validity = %d WHERE storage_uuid = '%q' AND folder_path='%q';",
+ sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_uuid='%q' AND folder_path='%q';",
MEDIA_SVC_DB_TABLE_FOLDER, validity, storage_id, start_path);
}
- ret = _media_svc_sql_query(sql, uid);
+ if (is_direct)
+ ret = _media_svc_sql_query_direct(sql, uid);
+ else
+ ret = _media_svc_sql_query(sql, uid);
SQLITE3_SAFE_FREE(sql);
diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c
index 1db7421..da5bf66 100755
--- a/src/common/media-svc-media.c
+++ b/src/common/media-svc-media.c
@@ -77,7 +77,7 @@ int _media_svc_get_modified_time(sqlite3 *handle, const char *storage_id, const
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, bool stack_query, uid_t uid)
+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 ret = MS_MEDIA_ERR_NONE;
@@ -180,7 +180,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
);
/* Check query length */
- if (sql != NULL && strlen(sql) >= (MEDIA_SVC_QUERY_LEN_MAX - 1)) {
+ if (sql != NULL && strlen(sql) >= (MEDIA_SVC_QUERY_LEN_MAX - 1) && is_direct == false) {
media_svc_debug("Query length is over %d byte.. So, remake query using only basic information..", MEDIA_SVC_QUERY_LEN_MAX - 1);
SQLITE3_SAFE_FREE(sql);
@@ -204,19 +204,23 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, me
content_info->sync_status,
content_info->file_name_pinyin,
content_info->storage_uuid,
- content_info->media_meta.is_360 /* 1st line */
+ content_info->media_meta.is_360
);
}
if (!stack_query) {
- ret = _media_svc_sql_query(sql, uid);
+ if (is_direct)
+ ret = _media_svc_sql_query_direct(sql, uid);
+ else
+ ret = _media_svc_sql_query(sql, uid);
+
SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("failed to insert item");
return ret;
}
} else {
- media_svc_debug("query : %s", sql);
+ media_svc_sec_debug("Query[%s]", sql);
_media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
}
@@ -279,7 +283,7 @@ int _media_svc_update_meta_with_data(media_svc_content_info_s *content_info)
);
if (sql != NULL) {
- media_svc_debug("query : %s", sql);
+ media_svc_debug("query[%s]", sql);
_media_svc_sql_query_add(&g_media_svc_update_item_query_list, &sql);
} else {
media_svc_error("sqlite3_mprintf failed");
@@ -416,7 +420,7 @@ int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *storage_id, c
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_delete_item_by_path(const char *storage_id, const char *path, bool stack_query, uid_t uid)
+int _media_svc_delete_item_by_path(bool is_direct, const char *storage_id, const char *path, bool stack_query, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *sql = NULL;
@@ -427,7 +431,10 @@ int _media_svc_delete_item_by_path(const char *storage_id, const char *path, boo
sql = sqlite3_mprintf("DELETE FROM '%q' WHERE media_path='%q';", storage_id, path);
if (!stack_query) {
- ret = _media_svc_sql_query(sql, uid);
+ if (is_direct)
+ ret = _media_svc_sql_query_direct(sql, uid);
+ else
+ ret = _media_svc_sql_query(sql, uid);
SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("failed to delete item");
@@ -454,7 +461,7 @@ int _media_svc_update_item_validity(const char *storage_id, const char *path, in
sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE media_path='%q';", storage_id, validity, path);
if (!stack_query) {
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
} else {
_media_svc_sql_query_add(&g_media_svc_item_validity_query_list, &sql);
@@ -511,32 +518,38 @@ int _media_svc_list_query_do(media_svc_query_type_e query_type, uid_t uid)
int ret = MS_MEDIA_ERR_NONE;
/* For multiples of 200, empty requests are possible */
- if (query_type == MEDIA_SVC_QUERY_UPDATE_COMMON) {
+ switch (query_type) {
+ case MEDIA_SVC_QUERY_UPDATE_COMMON:
if (g_media_svc_update_list == NULL || g_list_length(g_media_svc_update_list) == 0)
return MS_MEDIA_ERR_NONE;
- }
- ret = _media_svc_sql_begin_trans(uid);
- media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+ ret = _media_svc_sql_begin_trans(uid);
+ media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
- if (query_type == MEDIA_SVC_QUERY_SET_ITEM_VALIDITY)
- ret = _media_svc_sql_query_list(&g_media_svc_item_validity_query_list, uid);
- else if (query_type == MEDIA_SVC_QUERY_INSERT_ITEM)
- ret = _media_svc_sql_query_list(&g_media_svc_insert_item_query_list, uid);
- else if (query_type == MEDIA_SVC_QUERY_UPDATE_ITEM)
- ret = _media_svc_sql_query_list(&g_media_svc_update_item_query_list, uid);
- else if (query_type == MEDIA_SVC_QUERY_INSERT_FOLDER)
- ret = _media_svc_sql_query_list(_media_svc_get_folder_list_ptr(), uid);
- else if (query_type == MEDIA_SVC_QUERY_UPDATE_COMMON)
ret = _media_svc_sql_query_list(&g_media_svc_update_list, uid);
- else
- ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to request queries");
+
+ ret = _media_svc_sql_end_trans(uid);
+ break;
+ case MEDIA_SVC_QUERY_SET_ITEM_VALIDITY:
+ ret = _media_svc_sql_query_list_direct(&g_media_svc_item_validity_query_list, uid);
+ break;
+ case MEDIA_SVC_QUERY_INSERT_ITEM:
+ ret = _media_svc_sql_query_list_direct(&g_media_svc_insert_item_query_list, uid);
+ break;
+ case MEDIA_SVC_QUERY_UPDATE_ITEM:
+ ret = _media_svc_sql_query_list_direct(&g_media_svc_update_item_query_list, uid);
+ break;
+ case MEDIA_SVC_QUERY_INSERT_FOLDER:
+ ret = _media_svc_sql_query_list_direct(_media_svc_get_folder_list_ptr(), uid);
+ break;
+ default:
+ media_svc_error("Wrong type[%d]", query_type);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to request queries");
- ret = _media_svc_sql_end_trans(uid);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to batch insert");
-
return MS_MEDIA_ERR_NONE;
}
diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c
index 273d636..858b4fa 100755
--- a/src/common/media-svc-storage.c
+++ b/src/common/media-svc-storage.c
@@ -79,7 +79,7 @@ int _media_svc_append_storage(const char *storage_id, const char *storage_path,
char *sql = sqlite3_mprintf("INSERT INTO %q (storage_id, storage_path, storage_type) values (%Q, %Q, %d);",
MEDIA_SVC_DB_TABLE_STORAGE, storage_id, storage_path, storage_type);
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
return ret;
@@ -101,7 +101,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
/*Storage table update*/
sql = sqlite3_mprintf("UPDATE '%q' SET storage_path=%Q WHERE storage_id=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, path, storage_id);
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
G_SAFE_FREE(old_storage_path);
@@ -110,7 +110,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
/*Folder table update*/
sql = sqlite3_mprintf("UPDATE '%q' SET folder_path=REPLACE(folder_path, %Q, %Q) WHERE storage_uuid=%Q;", MEDIA_SVC_DB_TABLE_FOLDER, old_storage_path, path, storage_id);
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
G_SAFE_FREE(old_storage_path);
@@ -119,7 +119,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
/*Media table update*/
sql = sqlite3_mprintf("UPDATE '%q' SET media_path=REPLACE(media_path, %Q, %Q);", storage_id, old_storage_path, path);
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
G_SAFE_FREE(old_storage_path);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
@@ -182,7 +182,7 @@ int _media_svc_delete_invalid_storage(sqlite3 *handle, uid_t uid)
/* remove media before drop table (for clear playlist, and tag table)*/
sql = sqlite3_mprintf("DELETE FROM '%q';DROP TABLE '%q';", storage_id, storage_id);
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("Fail to drop table[%s]", storage_id);
@@ -195,7 +195,7 @@ int _media_svc_delete_invalid_storage(sqlite3 *handle, uid_t uid)
/* Update storage, folder table */
sql = sqlite3_mprintf("DELETE FROM %q WHERE validity=0;DELETE FROM %q WHERE validity=0;", MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_FOLDER);
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("Fail to update storage table");
@@ -228,7 +228,7 @@ int _media_svc_update_storage_validity(const char *storage_id, int validity, uid
else
sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE storage_id=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, validity, storage_id);
- ret = _media_svc_sql_query(sql, uid);
+ ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
return ret;
diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c
index fedb591..4758449 100755
--- a/src/common/media-svc-util.c
+++ b/src/common/media-svc-util.c
@@ -1292,7 +1292,7 @@ int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *conte
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, uid_t uid)
+int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid)
{
MMHandleType content = 0;
MMHandleType tag = 0;
@@ -1522,9 +1522,9 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s
media_svc_debug("album does not exist. So start to make album art");
if ((g_strcmp0(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN)) &&
(g_strcmp0(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN)))
- ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, content_info->thumbnail_path, &album_id, uid);
+ ret = _media_svc_append_album(handle, is_direct, content_info->media_meta.album, content_info->media_meta.artist, content_info->thumbnail_path, &album_id, uid);
else
- ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, NULL, &album_id, uid);
+ ret = _media_svc_append_album(handle, is_direct, content_info->media_meta.album, content_info->media_meta.artist, NULL, &album_id, uid);
content_info->album_id = album_id;
}
diff --git a/src/common/media-svc.c b/src/common/media-svc.c
index 6ae46f3..aab6eb5 100755
--- a/src/common/media-svc.c
+++ b/src/common/media-svc.c
@@ -189,8 +189,6 @@ int media_svc_get_modified_time(sqlite3 *handle, const char *storage_id, const c
int media_svc_insert_item_begin(int data_cnt, int with_noti, int from_pid)
{
- media_svc_debug("Transaction data count : [%d]", data_cnt);
-
media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
g_media_svc_insert_item_data_cnt = data_cnt;
@@ -261,11 +259,11 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
ret = _media_svc_extract_image_metadata(&content_info);
else
- ret = _media_svc_extract_media_metadata(handle, &content_info, uid);
+ ret = _media_svc_extract_media_metadata(handle, true, &content_info, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
/*Set or Get folder id*/
- ret = _media_svc_get_and_append_folder_id_by_path(handle, storage_id, path, storage_type, folder_uuid, uid);
+ ret = _media_svc_get_and_append_folder_id_by_path(handle, true, storage_id, path, storage_type, folder_uuid, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
content_info.folder_uuid = g_strdup(folder_uuid);
@@ -273,7 +271,7 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
if (g_media_svc_insert_item_data_cnt == 1) {
- ret = _media_svc_insert_item_with_data(handle, storage_id, &content_info, FALSE, uid);
+ ret = _media_svc_insert_item_with_data(handle, true, storage_id, &content_info, FALSE, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
@@ -281,7 +279,7 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
} else if (g_media_svc_insert_item_cur_data_cnt < (g_media_svc_insert_item_data_cnt - 1)) {
- ret = _media_svc_insert_item_with_data(handle, storage_id, &content_info, TRUE, uid);
+ ret = _media_svc_insert_item_with_data(handle, true, storage_id, &content_info, TRUE, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
@@ -291,7 +289,7 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
} else if (g_media_svc_insert_item_cur_data_cnt == (g_media_svc_insert_item_data_cnt - 1)) {
- ret = _media_svc_insert_item_with_data(handle, storage_id, &content_info, TRUE, uid);
+ ret = _media_svc_insert_item_with_data(handle, true, storage_id, &content_info, TRUE, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
@@ -349,13 +347,13 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, m
} else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
ret = _media_svc_extract_image_metadata(&content_info);
} else {
- ret = _media_svc_extract_media_metadata(handle, &content_info, uid);
+ ret = _media_svc_extract_media_metadata(handle, false, &content_info, uid);
}
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
/*Set or Get folder id*/
- ret = _media_svc_get_and_append_folder_id_by_path(handle, storage_id, path, storage_type, folder_uuid, uid);
+ ret = _media_svc_get_and_append_folder_id_by_path(handle, false, storage_id, path, storage_type, folder_uuid, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
content_info.folder_uuid = g_strdup(folder_uuid);
@@ -372,7 +370,7 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, m
}
}
- ret = _media_svc_insert_item_with_data(handle, storage_id, &content_info, FALSE, uid);
+ ret = _media_svc_insert_item_with_data(handle, false, storage_id, &content_info, FALSE, uid);
if (ret == MS_MEDIA_ERR_NONE) {
media_svc_debug("Insertion is successful. Sending noti for this");
@@ -417,7 +415,7 @@ int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*check and update folder*/
- ret = _media_svc_get_and_append_folder_id_by_path(handle, dst_stg_id, dest_path, dst_stg_type, folder_uuid, uid);
+ ret = _media_svc_get_and_append_folder_id_by_path(handle, false, dst_stg_id, dest_path, dst_stg_type, folder_uuid, uid);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*get filename*/
@@ -533,7 +531,7 @@ int media_svc_set_item_validity(const char *storage_id, const char *path, int va
return MS_MEDIA_ERR_NONE;
}
-int media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const char *path, 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 ret = MS_MEDIA_ERR_NONE;
char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0, };
@@ -556,7 +554,7 @@ int media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*Delete item*/
- ret = _media_svc_delete_item_by_path(storage_id, path, FALSE, uid);
+ ret = _media_svc_delete_item_by_path(is_direct, storage_id, path, FALSE, uid);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_delete_item_by_path failed : %d", ret);
_media_svc_destroy_noti_item(noti_item);
@@ -569,7 +567,7 @@ int media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const
_media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_DELETE, path, media_type, noti_item->media_uuid, noti_item->mime_type);
_media_svc_destroy_noti_item(noti_item);
} else {
- ret = _media_svc_delete_item_by_path(storage_id, path, TRUE, uid);
+ ret = _media_svc_delete_item_by_path(is_direct, storage_id, path, TRUE, uid);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_delete_item_by_path failed : %d", ret);
return ret;
@@ -646,7 +644,7 @@ int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_stor
else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
ret = _media_svc_extract_image_metadata(&content_info);
else
- ret = _media_svc_extract_media_metadata(handle, &content_info, uid);
+ ret = _media_svc_extract_media_metadata(handle, false, &content_info, uid);
if (ret != MS_MEDIA_ERR_NONE) {
_media_svc_destroy_noti_item(noti_item);
@@ -954,7 +952,7 @@ int media_svc_insert_folder(sqlite3 *handle, const char *storage_id, ms_user_sto
int media_svc_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(handle, storage_id, start_path, validity, is_recursive, uid);
+ return _media_svc_set_folder_validity(handle, true, storage_id, start_path, validity, is_recursive, uid);
}
int media_svc_check_folder_exist_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path)
diff --git a/src/include/common/media-svc-album.h b/src/include/common/media-svc-album.h
index 11ae80d..50d35f9 100755
--- a/src/include/common/media-svc-album.h
+++ b/src/include/common/media-svc-album.h
@@ -24,8 +24,9 @@
#include <sqlite3.h>
#include <sys/types.h>
+#include <stdbool.h>
int _media_svc_get_album_id(sqlite3 *handle, const char *album, const char *artist, int *album_id);
-int _media_svc_append_album(sqlite3 *handle, const char *album, const char *artist, const char *album_art, int *album_id, uid_t uid);
+int _media_svc_append_album(sqlite3 *handle, bool is_direct, const char *album, const char *artist, const char *album_art, int *album_id, uid_t uid);
#endif /*_MEDIA_SVC_ALBUM_H_*/
diff --git a/src/include/common/media-svc-db-utils.h b/src/include/common/media-svc-db-utils.h
index 816b3b8..f108155 100755
--- a/src/include/common/media-svc-db-utils.h
+++ b/src/include/common/media-svc-db-utils.h
@@ -36,12 +36,14 @@ void _media_svc_destroy_table_query();
int _media_svc_create_media_table_with_id(const char *table_id, uid_t uid);
int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid);
int _media_svc_sql_query(const char *sql_str, uid_t uid);
+int _media_svc_sql_query_direct(const char *sql_str, uid_t uid);
int _media_svc_get_user_version(sqlite3 *db_handle, int *user_version);
int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt);
int _media_svc_sql_prepare_to_step_simple(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt);
int _media_svc_sql_begin_trans(uid_t uid);
int _media_svc_sql_end_trans(uid_t uid);
int _media_svc_sql_query_list(GList **query_list, uid_t uid);
+int _media_svc_sql_query_list_direct(GList **query_list, uid_t uid);
void _media_svc_sql_query_add(GList **query_list, char **query);
void _media_svc_sql_query_release(GList **query_list);
int _media_svc_check_db_upgrade(sqlite3 *db_handle, int user_version, uid_t uid);
diff --git a/src/include/common/media-svc-media-folder.h b/src/include/common/media-svc-media-folder.h
index f8a6969..284c4fb 100755
--- a/src/include/common/media-svc-media-folder.h
+++ b/src/include/common/media-svc-media-folder.h
@@ -29,10 +29,10 @@
int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid);
int _media_svc_get_folder_id_by_foldername_with_validity(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid, int *validity);
int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, uid_t uid);
-int _media_svc_get_and_append_folder(sqlite3 *handle, 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_path(sqlite3 *handle, 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(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_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, char *folder_id, bool stack_query, uid_t uid);
-int _media_svc_set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid);
+int _media_svc_set_folder_validity(sqlite3 *handle, bool is_direct, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid);
GList ** _media_svc_get_folder_list_ptr(void);
int _media_svc_count_folder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count);
diff --git a/src/include/common/media-svc-media.h b/src/include/common/media-svc-media.h
index 0291193..723226d 100755
--- a/src/include/common/media-svc-media.h
+++ b/src/include/common/media-svc-media.h
@@ -30,11 +30,11 @@
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, const char *storage_id, media_svc_content_info_s *content_info, bool stack_query, uid_t uid);
+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_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(const char *storage_id, const char *path, bool stack_query, uid_t uid);
+int _media_svc_delete_item_by_path(bool is_direct, const char *storage_id, const char *path, bool stack_query, uid_t uid);
int _media_svc_update_item_validity(const char *storage_id, const char *path, int validity, bool stack_query, uid_t uid);
int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, ms_user_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, uid_t uid);
int _media_svc_list_query_do(media_svc_query_type_e query_type, uid_t uid);
diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h
index fc3f8d2..d148d96 100755
--- a/src/include/common/media-svc-util.h
+++ b/src/include/common/media-svc-util.h
@@ -141,7 +141,7 @@ int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool re
int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type,
const char *path, media_svc_media_type_e *media_type, bool refresh);
int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info);
-int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, uid_t uid);
+int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid);
time_t __media_svc_get_timeline_from_str(const char *timstr);
void _media_svc_destroy_content_info(media_svc_content_info_s *content_info);
int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid);