eDELETE_INVALID_FOLDER_BY_PATH,
eCHECK_FOLDER_EXIST,
eGET_MEDIA_TYPE,
- eGET_EXTRACT_LIST,
- eUPDATE_ONE_EXTRACT_ITEM,
+ eGET_AND_EXTRACT_MEDIA,
eREFRESH_ITEM,
eFUNC_MAX
};
"delete_invalid_folder_by_path",
"check_folder_exist",
"get_media_type",
- "get_extract_list",
- "update_one_extract_item",
+ "get_and_extract_media",
"refresh_item",
};
} else {
*modified = false;
#ifdef _USE_TVPD_MODE
- char* folder_id_media = NULL;
- char* folder_id_folder = NULL;
+ char *folder_id_media = NULL;
+ char *folder_id_folder = NULL;
folder_id_media = (char *)sqlite3_column_text(sql_stmt, 4);
- char* folder_path = NULL;
+ char *folder_path = NULL;
folder_path = g_path_get_dirname(path);
ret = ms_get_folder_id(handle, storage_id, folder_path, &folder_id_folder);
g_free(folder_path);
return ret;
}
-int ms_insert_item_batch(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 ret = MS_MEDIA_ERR_NONE;
ms_user_storage_type_e storage_type = -1;
return ret;
}
-int ms_scan_item_batch(sqlite3 *handle, const char* storage_id, const char *path, uid_t uid)
+int ms_scan_item_batch(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;
return ret;
}
-int ms_get_extract_list(sqlite3 *handle, const char* storage_id, int storage_type, int scan_type, const char* path, int is_end, uid_t uid, void* array)
+int ms_get_and_extract_media(sqlite3 *handle, const char *storage_id, int scan_type, const char *path)
{
int ret = MS_MEDIA_ERR_NONE;
- ret = ((GET_EXTRACT_LIST)func_array[eGET_EXTRACT_LIST])(handle, storage_id, storage_type, scan_type, path, is_end, uid, array); /*dlopen*/
+ ret = ((GET_AND_EXTRACT_MEDIA)func_array[eGET_AND_EXTRACT_MEDIA])(handle, storage_id, scan_type, path); /*dlopen*/
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "GET_EXTRACT_LIST failed [%d]", ret);
return ret;
}
-int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, int storage_type, void* data)
-{
- int ret = MS_MEDIA_ERR_NONE;
-
- ret = ((UPDATE_ONE_EXTRACT_ITEM)func_array[eUPDATE_ONE_EXTRACT_ITEM])(handle, storage_id, storage_type, data); /*dlopen*/
- MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "UPDATE_ONE_EXTRACT_ITEM failed [%d]", ret);
-
- return ret;
-}
-
int ms_delete_invalid_items(sqlite3 *handle, const char *storage_id, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
return ret;
}
-int ms_delete_invalid_items_in_folder(sqlite3 *handle, const char* storage_id, const char*path, bool is_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 ret = MS_MEDIA_ERR_NONE;
static int stg_extract_status;
static GMutex extract_item_mutex;
-static GMutex decode_mutex;
static s_extract_item* cancel_extract_item = NULL;
static s_extract_item* cur_extract_item = NULL;
static GCond extract_data_cond;
static GMutex extract_data_mutex;
#define VCONFKEY_PRIVATE_EXTRACTSTATUS "db/private/extractstatus"
-#define LAST_EVENT 1
-#define NORMAL_EVENT 0
-static int __msc_check_extract_stop_status(int scan_type, const char *start_path, int pid, bool is_end);
+static int __msc_check_extract_stop_status(int scan_type, const char *start_path, int pid);
static void __msc_set_storage_extract_status(ms_storage_scan_status_e status);
static void __msc_get_storage_extract_status(ms_storage_scan_status_e *status);
static void __msc_resume_extract(void);
static void __msc_del_cur_extract_item(void);
static void __msc_del_extract_blocked_path(const char* blocked_path);
-
-typedef struct {
- int media_type;
- char *path;
-} ms_item_info_s;
-
void msc_init_extract_thread(void)
{
if (!storage_extract_queue) storage_extract_queue = g_async_queue_new();
g_mutex_init(&extract_data_mutex);
g_mutex_init(&extract_item_mutex);
- g_mutex_init(&decode_mutex);
g_cond_init(&extract_data_cond);
}
g_mutex_clear(&extract_data_mutex);
g_mutex_clear(&extract_item_mutex);
- g_mutex_clear(&decode_mutex);
g_cond_clear(&extract_data_cond);
}
-static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, int storage_type, const char *path, int scan_type, int pid, uid_t uid, bool is_end)
+static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, const char *path, int scan_type, int pid)
{
- MS_DBG_WARN("begin of __msc_folder_bulk_extract");
int ret = MS_MEDIA_ERR_NONE;
- GArray *data_array = NULL;
- ms_item_info_s* db_data = NULL;
- int sleep_count = 0;
- ret = ms_get_extract_list(handle, storage_id, storage_type, scan_type, path, is_end, uid, (void *)&data_array);
- MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_NONE, "ms_get_extract_list failed!!!");
- MS_DBG_RETVM_IF(!data_array, MS_MEDIA_ERR_NONE, "data_array is NULL!!!");
-
- while (data_array->len != 0) {
- db_data = NULL;
+ MS_DBG_FENTER();
- ret = __msc_check_extract_stop_status(scan_type, path, pid, is_end);
+ while (1) {
+ ret = __msc_check_extract_stop_status(scan_type, path, pid);
if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
MS_DBG_ERR("__msc_folder_bulk_extract MS_MEDIA_ERR_SCANNER_FORCE_STOP");
break;
}
- db_data = g_array_index(data_array, ms_item_info_s*, 0);
- g_array_remove_index(data_array, 0);
-
- g_mutex_lock(&decode_mutex);
- ms_update_one_extract_item(handle, storage_id, storage_type, db_data);
- g_mutex_unlock(&decode_mutex);
-
- if (db_data) {
- g_free(db_data->path);
- g_free(db_data);
- db_data = NULL;
- }
+ ret = ms_get_and_extract_media(handle, storage_id, scan_type, path);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
+ MS_DBG("Extract done");
+ else
+ MS_DBG_ERR("ms_get_and_extract_media failed!!!");
- if (++sleep_count == 5) {
- sleep_count = 0;
- usleep(SCAN_SLEEP_TIME);
+ break;
}
+ /* Sleep per 10 items. refer to META_UPDATE_MAX */
+ usleep(SCAN_SLEEP_TIME);
}
- while (data_array->len != 0) {
- db_data = g_array_index(data_array, ms_item_info_s *, 0);
- g_array_remove_index(data_array, 0);
-
- if (db_data) {
- g_free(db_data->path);
- g_free(db_data);
- db_data = NULL;
- }
- }
- g_array_free(data_array, FALSE);
- data_array = NULL;
+ MS_DBG_FLEAVE();
- MS_DBG_WARN("end of __msc_folder_bulk_extract");
- return ret;
+ return MS_MEDIA_ERR_NONE;
}
gpointer msc_folder_extract_thread(gpointer data)
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
int scan_type;
- ms_user_storage_type_e storage_type;
char *storage_id = NULL;
char *update_path = NULL;
uid_t uid = MEDIA_DEFAULT_UID;
- int end_flag = NORMAL_EVENT;
ms_noti_type_e noti_type = MS_ITEM_INSERT;
while (1) {
g_directory_extract_processing = true;
uid = extract_data->uid;
- /*connect to media db, if conneting is failed, db updating is stopped*/
+ /*connect to media db, if connecting is failed, db updating is stopped*/
ret = ms_connect_db(&handle, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_connect_db failed");
ret = MS_MEDIA_ERR_INVALID_PARAMETER;
goto NEXT;
}
- 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) {
- MS_DBG_ERR("ms_user_get_storage_type failed");
- goto NEXT;
- }
-
- ret = __msc_check_extract_stop_status(extract_data->msg_type, update_path, extract_data->pid, end_flag);
+ ret = __msc_check_extract_stop_status(extract_data->msg_type, update_path, extract_data->pid);
if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
MS_DBG_ERR("MS_MEDIA_ERR_SCANNER_FORCE_STOP");
goto NEXT;
}
- ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, extract_data->pid, uid, end_flag);
+ ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, update_path, scan_type, extract_data->pid);
NEXT:
g_directory_extract_processing = false;
int scan_type;
char *update_path = NULL;
uid_t uid = MEDIA_DEFAULT_UID;
- int end_flag = NORMAL_EVENT;
int tem_ret = MS_MEDIA_ERR_NONE;
while (1) {
uid = extract_data->uid;
- /*connect to media db, if conneting is failed, db updating is stopped*/
+ /*connect to media db, if connecting is failed, db updating is stopped*/
ret = ms_connect_db(&handle, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_connect_db falied!");
continue;
}
- end_flag = extract_data->result ? LAST_EVENT : NORMAL_EVENT;
update_path = g_strdup(extract_data->msg);
if (!MS_STRING_VALID(update_path)) {
MS_DBG_ERR("Invalid update_path");
}
/*extract meta*/
- ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, update_path, scan_type, extract_data->pid, uid, end_flag);
+ ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, update_path, scan_type, extract_data->pid);
MS_DBG_WARN("extract PAUSE");
__msc_pause_extract();
MS_DBG_WARN("extract RESUME");
- tem_ret = __msc_check_extract_stop_status(extract_data->msg_type, update_path, extract_data->pid, end_flag);
+ tem_ret = __msc_check_extract_stop_status(extract_data->msg_type, update_path, extract_data->pid);
if (tem_ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
ms_set_storage_scan_status(handle, extract_data->storage_id, MEDIA_EXTRACT_STOP, uid);
__msc_set_storage_extract_status(MS_STORAGE_SCAN_META_STOP);
MS_DBG_FLEAVE();
}
-static int __msc_check_extract_stop_status(int scan_type, const char *start_path, int pid, bool is_end)
+static int __msc_check_extract_stop_status(int scan_type, const char *start_path, int pid)
{
int ret = MS_MEDIA_ERR_NONE;
/*check poweroff status*/
- if (_msc_is_power_off()) {
- ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
- goto END;
- }
+ MS_DBG_RETV_IF(_msc_is_power_off(), MS_MEDIA_ERR_SCANNER_FORCE_STOP);
if (scan_type == MS_MSG_DIRECTORY_SCANNING || scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
g_mutex_lock(&extract_req_mutex);
MS_DBG_SERR("Receive blocked message[%s][%s]. STOP extract!!", g_extract_blocked_path, start_path);
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
}
- if (is_end) {
- MS_DBG("[END REQUEST]");
- /*MS_SAFE_FREE(g_extract_blocked_path);*/
- } else {
- MS_DBG("[NOT END REQUEST]");
- }
}
g_mutex_unlock(&extract_blocked_mutex);
}
-END:
+
return ret;
}
/* make new array for storing directory */
dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
- /* add first direcotiry to directory array */
+ /* add first directory to directory array */
new_start_path = g_strdup(start_path);
g_array_append_val(dir_array, start_path);
g_directory_scan_processing2 = DIR_SCAN_NON_RECURSIVE;
uid = scan_data->uid;
- /*connect to media db, if conneting is failed, db updating is stopped*/
+ /*connect to media db, if connecting is failed, db updating is stopped*/
ret = ms_connect_db(&handle, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_connect_db failed");
MS_DBG_WARN("folder scan done, sent cb event path = [%.*s]", MAX_MSG_SIZE, scan_data->msg);
__msc_call_dir_scan_cb();
- /*delete invalid folder first, then delete invalid item, avoid to folder was deleted but item not when unmount*/
- /*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 (!ms_delete_invalid_items(handle, storage_id, storage_type, scan_data->uid))
- MS_DBG_ERR("deleting invalid items in storage failed");*/
-
/*revert to 3.0,folder scan should only delete invalid in folder instead of delete invalid in storage*/
- if (ms_delete_invalid_items_in_folder(handle, storage_id, scan_data->msg, is_recursive, uid) != MS_MEDIA_ERR_NONE) {
+ if (ms_delete_invalid_items_in_folder(handle, storage_id, scan_data->msg, is_recursive, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("deleting invalid items in folder failed");
- }
-
- /*if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
- ms_send_dir_update_noti(scan_data->msg, folder_uuid, noti_type, scan_data->pid);
- }*/
SCAN_DONE:
MS_DBG_WARN("storage_id = [%s], dir Path = [%.*s], pid = [%d]", storage_id, MAX_MSG_SIZE, scan_data->msg, scan_data->pid);
uid = scan_data->uid;
- /*connect to media db, if conneting is failed, db updating is stopped*/
+ /*connect to media db, if connecting is failed, db updating is stopped*/
ret = ms_connect_db(&handle, uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_connect_db failed");
/* check valid path */
ret = ms_check_ignore_dir(path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_SERR("invalide path : %s", path);
+ MS_DBG_SERR("Invalid path : %s", path);
g_free(path);
continue;
}