int media_db_request_update_db(const char *query_str, uid_t uid);
+int media_db_update_db_direct(const char *query_str, uid_t uid);
+
int media_db_request_update_db_batch_start(const char *query_str, uid_t uid);
int media_db_request_update_db_batch(const char *query_str, uid_t uid);
return ret;
}
+int media_db_update_db_direct(const char *query_str, uid_t uid)
+{
+ int ret = MS_MEDIA_ERR_NONE;
+ sqlite3 *handle = NULL;
+
+ MSAPI_DBG_FUNC();
+
+ MSAPI_RETVM_IF(!MS_STRING_VALID(query_str), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid Query");
+
+ ret = media_db_connect(&handle, uid, true);
+ MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Connect failed");
+
+ ret = _media_db_update_directly(handle, query_str);
+ if (ret != MS_MEDIA_ERR_NONE)
+ MSAPI_DBG_ERR("Query failed");
+
+ media_db_disconnect(handle);
+
+ return ret;
+}
+
int media_db_request_update_db_batch_start(const char *query_str, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
int ms_validate_item(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
int ms_insert_item_batch(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
int ms_validity_change_all_items(sqlite3 *handle, const char *storage_id, bool validity, uid_t uid);
-bool ms_delete_invalid_items(sqlite3 *handle, const char *storage_id, uid_t uid);
+int ms_delete_invalid_items(sqlite3 *handle, const char *storage_id, uid_t uid);
int ms_set_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *path, int validity, int recursive, uid_t uid);
int ms_delete_invalid_items_in_folder(sqlite3 *handle, const char *storage_id, const char *path, bool is_recursive, uid_t uid);
int ms_send_dir_update_noti(const char *path, const char *folder_id, ms_noti_type_e noti_type, int pid);
char *sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d;", storage_id, validity);
- ret = media_db_request_update_db(sql, uid);
+ ret = media_db_update_db_direct(sql, uid);
MS_SQLITE3_SAFE_FREE(sql);
return ret;
return ret;
}
-bool ms_delete_invalid_items(sqlite3 *handle, const char *storage_id, uid_t uid)
+int ms_delete_invalid_items(sqlite3 *handle, const char *storage_id, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
MS_SQLITE3_FINALIZE(sql_stmt);
- sql = sqlite3_mprintf("DELETE FROM '%q' WHERE validity = 0;", storage_id);
+ sql = sqlite3_mprintf("DELETE FROM '%q' WHERE validity=0;", storage_id);
- ret = media_db_request_update_db(sql, uid);
+ ret = media_db_update_db_direct(sql, uid);
MS_SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
while ((thumb_list != NULL) && (thumb_list->len != 0)) {
else
sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE folder_id IN (SELECT folder_id FROM folder WHERE folder_path='%q' AND storage_uuid='%q');", storage_id, validity, path, storage_id);
- ret = media_db_request_update_db(sql, uid);
+ ret = media_db_update_db_direct(sql, uid);
MS_SQLITE3_SAFE_FREE(sql);
return ret;
sql = sqlite3_mprintf("DELETE FROM folder WHERE storage_uuid='%q' AND validity=0;", storage_id);
- ret = media_db_request_update_db(sql, uid);
+ ret = media_db_update_db_direct(sql, uid);
MS_SQLITE3_SAFE_FREE(sql);
if (scan_type == MS_MSG_STORAGE_ALL) {
/* Delete all data before full scanning */
- if (!ms_delete_invalid_items(handle, scan_data->storage_id, uid))
+ if (ms_delete_invalid_items(handle, scan_data->storage_id, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("ms_delete_invalid_items fails");
}
ms_batch_commit_disable(true, true, scan_data->uid);
- if (!ms_delete_invalid_items(handle, storage_id, scan_data->uid))
+ if (ms_delete_invalid_items(handle, storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("deleting invalid items in storage failed");
if (ms_delete_invalid_folder(storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE)
ms_batch_commit_disable(true, valid_status, scan_data->uid);
if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE) {
- if (!ms_delete_invalid_items(handle, storage_id, scan_data->uid))
+ if (ms_delete_invalid_items(handle, storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("deleting invalid items in storage failed");
if (ms_delete_invalid_folder(storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE)