else
ret = db_util_open_with_options(db_path, db_handle, SQLITE_OPEN_READONLY, NULL);
- MS_SAFE_FREE(db_path);
if (SQLITE_OK != ret) {
- MSAPI_DBG_ERR("error when db open [%s]", db_path);
+ MSAPI_DBG_ERR("error when db open path[%s],ret[%d]", db_path, ret);
+ MS_SAFE_FREE(db_path);
*db_handle = NULL;
return MS_MEDIA_ERR_DB_CONNECT_FAIL;
}
+ MS_SAFE_FREE(db_path);
if (*db_handle == NULL) {
MSAPI_DBG_ERR("*db_handle is NULL");
ret = sqlite3_exec(db_handle, sql_str, NULL, NULL, &zErrMsg);
if (SQLITE_OK != ret) {
- MSAPI_ERR_SLOG("Query[%s] Error[%s]", sql_str, zErrMsg);
+ MSAPI_ERR_SLOG("Error[%s],Query[%s]", zErrMsg, sql_str);
MS_SQL_SAFE_FREE(zErrMsg);
if (ret == SQLITE_BUSY) {
ret = MS_MEDIA_ERR_DB_BUSY_FAIL;
gboolean msc_folder_extract_thread(void *data)
{
ms_comm_msg_s *extract_data = NULL;
- int err;
- int ret;
+ int ret = MS_MEDIA_ERR_NONE;
void **handle = NULL;
int scan_type;
ms_user_storage_type_e storage_type;
uid = extract_data->uid;
/*connect to media db, if conneting is failed, db updating is stopped*/
- err = ms_connect_db(&handle, uid);
- if (err != MS_MEDIA_ERR_NONE)
- continue;
+ ret = ms_connect_db(&handle, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_connect_db failed");
+ goto NEXT;
+ }
scan_type = extract_data->msg_type;
end_flag = extract_data->result ? LAST_EVENT : NORMAL_EVENT;
ret = ms_user_get_storage_type(uid, extract_data->msg, &storage_type);
- if (ret != MS_MEDIA_ERR_NONE)
+ if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_user_get_storage_type failed");
+ goto NEXT;
+ }
ret = __msc_check_extract_stop_status(extract_data->msg_type, storage_type, update_path, extract_data->pid, end_flag);
malloc_trim(0);
if (extract_data->result) {
+ /*send notification*/
+ char *folder_uuid = NULL;
+ ms_get_folder_id(handle, storage_id, extract_data->msg, &folder_uuid);
+ ms_send_dir_update_noti(handle, storage_id, update_path, folder_uuid, MS_ITEM_UPDATE, extract_data->pid);
extract_data->msg_type = MS_MSG_EXTRACTOR_COMPLETE;
msc_send_result(ret, extract_data);
}
gboolean msc_storage_extract_thread(void *data)
{
ms_comm_msg_s *extract_data = NULL;
- int ret;
- int err;
+ int ret = MS_MEDIA_ERR_NONE;
void **handle = NULL;
ms_user_storage_type_e storage_type = MS_STORAGE_INTERNAL;
int scan_type;
uid = extract_data->uid;
/*connect to media db, if conneting is failed, db updating is stopped*/
- err = ms_connect_db(&handle, uid);
- if (err != MS_MEDIA_ERR_NONE) {
+ ret = ms_connect_db(&handle, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_connect_db falied!");
continue;
}
}
ret = ms_user_get_storage_type(uid, extract_data->msg, &storage_type);
- if (ret != MS_MEDIA_ERR_NONE)
+ if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_user_get_storage_type failed");
+ goto NEXT;
+ }
/*extract meta*/
ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, end_flag, extract_data->pid, uid, &io_err_count, end_flag);
MS_DBG_WARN("extract_data->result == TRUE, MS_STORAGE_SCAN_COMPLETE");
ms_set_storage_scan_status(handle, extract_data->storage_id, MEDIA_EXTRACT_COMPLETE, uid);
__msc_set_storage_extract_status(MS_STORAGE_SCAN_COMPLETE);
+
+ /* send notification */
+ ms_send_dir_update_noti(handle, extract_data->storage_id, update_path, NULL, MS_ITEM_UPDATE, extract_data->pid);
/* set vconf key db extract status */
__msc_extract_set_db_status(MS_DB_UPDATED);
if (msc_get_disc_stg_scan_status()) {
int index = 0;
ms_user_storage_type_e storage_type = MS_STORAGE_INTERNAL;
ms_dir_scan_status_e scan_status = MS_DIR_SCAN_NONE;
- ms_noti_type_e noti_type = MS_ITEM_INSERT;
char *folder_uuid = NULL;
uid_t uid = MEDIA_DEFAULT_UID;
uid = scan_data->uid;
/*connect to media db, if conneting is failed, db updating is stopped*/
- err = ms_connect_db(&handle, uid);
- if (err != MS_MEDIA_ERR_NONE)
- continue;
+ ret = ms_connect_db(&handle, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_connect_db failed");
+ goto NEXT;
+ }
/*check remain space*/
err = __msc_check_remain_space(uid);
}
scan_type = scan_data->msg_type;
- err = ms_user_get_storage_type(uid, scan_data->msg, &storage_type);
- if (err != MS_MEDIA_ERR_NONE)
+ ret = ms_user_get_storage_type(uid, scan_data->msg, &storage_type);
+ if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_user_get_storage_type failed");
+ goto NEXT;
+ }
storage_id = strdup(scan_data->storage_id);
if (storage_id == NULL) {
if (g_file_test(scan_data->msg, G_FILE_TEST_IS_DIR)) {
if (ms_check_folder_exist(handle, storage_id, scan_data->msg) == MS_MEDIA_ERR_NONE) {
/*already exist in media DB*/
- noti_type = MS_ITEM_UPDATE;
MS_DBG_WARN("[%s] already exist", scan_data->msg);
} else {
- noti_type = MS_ITEM_INSERT;
MS_DBG_WARN("[%s] new insert path", scan_data->msg);
}
} else {
/*directory is deleted*/
- noti_type = MS_ITEM_DELETE;
scan_type = MS_MSG_DIRECTORY_SCANNING;
scan_data->msg_type = MS_MSG_DIRECTORY_SCANNING;
if (ms_delete_invalid_folder(handle, storage_id, storage_type, scan_data->uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("deleting invalid folders in storage failed");
- if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
+ /*if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
MS_DBG_INFO("working normally");
ms_send_dir_update_noti(handle, storage_id, scan_data->msg, folder_uuid, noti_type, scan_data->pid);
- }
+ }*/
SCAN_DONE:
MS_DBG_WARN("storage_id = [%s], dir Path = [%s]", storage_id, scan_data->msg);
gboolean msc_storage_scan_thread(void *data)
{
ms_comm_msg_s *scan_data = NULL;
- int ret;
- int err;
+ int ret = MS_MEDIA_ERR_NONE;
void **handle = NULL;
ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
int scan_type;
uid = scan_data->uid;
/*connect to media db, if conneting is failed, db updating is stopped*/
- err = ms_connect_db(&handle, uid);
- if (err != MS_MEDIA_ERR_NONE)
- continue;
+ ret = ms_connect_db(&handle, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_connect_db failed");
+ goto NEXT;
+ }
- err = ms_user_get_storage_type(uid, scan_data->msg, &storage_type);
- if (err != MS_MEDIA_ERR_NONE)
+ ret = ms_user_get_storage_type(uid, scan_data->msg, &storage_type);
+ if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_user_get_storage_type failed");
+ goto NEXT;
+ }
update_path = g_strndup(scan_data->msg, scan_data->msg_size);
if (!MS_STRING_VALID(update_path)) {
goto NEXT;
}
- err = __msc_check_memory_status(uid);
- if (err != MS_MEDIA_ERR_NONE) {
- ret = err;
+ ret = __msc_check_memory_status(uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
ms_set_storage_scan_status(handle, scan_data->storage_id, MEDIA_SCAN_STOP, uid);
MS_DBG_ERR("storage_id = [%s]", scan_data->storage_id);
msc_insert_exactor_request(scan_type, TRUE, scan_data->storage_id, scan_data->msg, scan_data->pid, uid);
ms_delete_invalid_items(handle, scan_data->storage_id, storage_type, uid);
/* send notification */
- ms_send_dir_update_noti(handle, scan_data->storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);
+ /*ms_send_dir_update_noti(handle, scan_data->storage_id, update_path, NULL, MS_ITEM_UPDATE, scan_data->pid);*/
if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
ms_set_storage_scan_status(handle, scan_data->storage_id, MEDIA_SCAN_STOP, uid);