int ms_set_storage_scan_status(sqlite3 *handle, char *storage_id, media_scan_status_e scan_status, uid_t uid);
int ms_genarate_uuid(char **uuid);
int ms_scan_item_batch(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
-int ms_get_and_extract_media(sqlite3 *handle, const char *storage_id, int scan_type, const char *path);
+int ms_get_and_extract_media(sqlite3 *handle, const char *storage_id, ms_msg_type_e msg_type, const char *path);
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_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid);
int ms_get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *scan_status);
return ret;
}
-int ms_get_and_extract_media(sqlite3 *handle, const char *storage_id, int scan_type, const char *path)
+int ms_get_and_extract_media(sqlite3 *handle, const char *storage_id, ms_msg_type_e msg_type, const char *path)
{
int ret = MS_MEDIA_ERR_NONE;
- ret = ((GET_AND_EXTRACT_MEDIA)func_array[eGET_AND_EXTRACT_MEDIA])(handle, storage_id, scan_type, path);
+ ret = ((GET_AND_EXTRACT_MEDIA)func_array[eGET_AND_EXTRACT_MEDIA])(handle, storage_id, msg_type, path);
if (ret != MS_MEDIA_ERR_NONE && ret != MS_MEDIA_ERR_DB_NO_RECORD)
MS_DBG_ERR("GET_AND_EXTRACT_MEDIA failed [%d]", ret);
#include "media-common-types.h"
-int msc_check_db_size(uid_t uid, int scan_type);
+int msc_check_db_size(uid_t uid, ms_msg_type_e msg_type);
int msc_cleanup_invalid_values(uid_t uid);
#endif
void msc_deinit_extract_thread(void);
gpointer msc_folder_extract_thread(gpointer data);
gpointer msc_storage_extract_thread(gpointer data);
-void msc_insert_exactor_request(int message_type, bool ins_status, const char *storage_id, const char *path, int pid, uid_t uid, ms_noti_type_e noti_type);
+void msc_insert_exactor_request(ms_msg_type_e msg_type, bool ins_status, const char *storage_id, const char *path, int pid, uid_t uid, ms_noti_type_e noti_type);
int msc_remove_extract_request(const ms_comm_msg_s *recv_msg);
int msc_set_cancel_extract_item(const char* path, int pid);
void msc_set_extract_blocked_path(const char *blocked_path);
#include "media-scanner-dbg-v2.h"
#include "media-scanner-db-manage-v2.h"
-int msc_check_db_size(uid_t uid, int scan_type)
+int msc_check_db_size(uid_t uid, ms_msg_type_e msg_type)
{
double db_size = 0.0;
double free_space = 0.0;
ms_check_size_mediadb(uid, &db_size);
- if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL) {
+ if (msg_type == MS_MSG_STORAGE_ALL || msg_type == MS_MSG_STORAGE_PARTIAL) {
if (db_size >= MEDIA_DB_SIZE_LIMIT_1) {
MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_1[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_1);
return MS_MEDIA_ERR_DB_LIMIT_1;
}
- } else if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE || scan_type == MS_MSG_DIRECTORY_SCANNING) {
+ } else if (msg_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE || msg_type == MS_MSG_DIRECTORY_SCANNING) {
if (db_size >= MEDIA_DB_SIZE_LIMIT_2) {
MS_DBG_ERR("DB SIZE [%lf] reach the MEDIA_DB_SIZE_LIMIT_2[%lf]", db_size, MEDIA_DB_SIZE_LIMIT_2);
static GMutex extract_data_mutex;
#define VCONFKEY_PRIVATE_EXTRACTSTATUS "db/private/extractstatus"
-static int __msc_check_extract_stop_status(int scan_type, const char *start_path, int pid);
+static int __msc_check_extract_stop_status(ms_msg_type_e msg_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);
g_cond_clear(&extract_data_cond);
}
-static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, const char *path, int scan_type, int pid)
+static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, const char *path, ms_msg_type_e msg_type, int pid)
{
int ret = MS_MEDIA_ERR_NONE;
MS_DBG_FENTER();
while (1) {
- ret = __msc_check_extract_stop_status(scan_type, path, pid);
+ ret = __msc_check_extract_stop_status(msg_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;
}
- ret = ms_get_and_extract_media(handle, storage_id, scan_type, path);
+ ret = ms_get_and_extract_media(handle, storage_id, msg_type, path);
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_NO_RECORD)
MS_DBG("Extract done");
return NULL;
}
-void msc_insert_exactor_request(int message_type, bool ins_status, const char *storage_id, const char *path, int pid, uid_t uid, ms_noti_type_e noti_type)
+void msc_insert_exactor_request(ms_msg_type_e msg_type, bool ins_status, const char *storage_id, const char *path, int pid, uid_t uid, ms_noti_type_e noti_type)
{
ms_comm_msg_s *extract_data = g_new0(ms_comm_msg_s, 1);
- extract_data->msg_type = message_type;
+ extract_data->msg_type = msg_type;
extract_data->pid = pid;
extract_data->uid = uid;
extract_data->result = ins_status;
SAFE_STRLCPY(extract_data->msg, path, sizeof(extract_data->msg));
SAFE_STRLCPY(extract_data->storage_id, storage_id, sizeof(extract_data->storage_id));
- if (message_type == MS_MSG_STORAGE_ALL || message_type == MS_MSG_STORAGE_PARTIAL || message_type == MS_MSG_STORAGE_INVALID) {
+ MS_DBG("msg_type [%d] ins_status[%d]", msg_type, ins_status);
+ if (msg_type == MS_MSG_STORAGE_ALL || msg_type == MS_MSG_STORAGE_PARTIAL || msg_type == MS_MSG_STORAGE_INVALID) {
g_async_queue_push(storage_extract_queue, extract_data);
- MS_DBG("insert to storage exactor queue. msg_type [%d]", ins_status);
- } else if (message_type == MS_MSG_DIRECTORY_SCANNING || message_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
+ MS_DBG("insert to storage exactor queue");
+ } else if (msg_type == MS_MSG_DIRECTORY_SCANNING || msg_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
g_async_queue_push(folder_extract_queue, extract_data);
- MS_DBG("insert to dir exactor queue. msg_type [%d]", ins_status);
+ MS_DBG("insert to dir exactor queue");
} else {
- MS_DBG_ERR("try to insert to exactor scan with msg_type [%d]", message_type);
+ MS_DBG_ERR("wrong msg_type");
g_free(extract_data);
}
}
MS_DBG_FLEAVE();
}
-static int __msc_check_extract_stop_status(int scan_type, const char *start_path, int pid)
+static int __msc_check_extract_stop_status(ms_msg_type_e msg_type, const char *start_path, int pid)
{
int ret = MS_MEDIA_ERR_NONE;
/*check poweroff status*/
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) {
+ if (msg_type == MS_MSG_DIRECTORY_SCANNING || msg_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
g_mutex_lock(&extract_req_mutex);
/* check cancel path */
//MS_DBG_ERR("__msc_check_extract_stop_status...");
g_mutex_unlock(&extract_req_mutex);
}
- if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL) {
+ if (msg_type == MS_MSG_STORAGE_ALL || msg_type == MS_MSG_STORAGE_PARTIAL) {
if (g_directory_extract_processing == true) {
MS_DBG_WARN("Now directory extract is start. So, storage extract is stopped.");
__msc_pause_extract();
static char* g_dir_scan_path;
static bool is_scanner_paused = false;
-static int __msc_check_stop_status(int scan_type, const char *start_path, int pid);
+static int __msc_check_stop_status(ms_msg_type_e msg_type, const char *start_path, int pid);
static int __msc_get_null_scan_folder_list(sqlite3 *handle, const char *stroage_id, char *path, GPtrArray *dir_array);
static int __msc_check_scan_same_path(char *scan_path);
static void __msc_set_storage_scan_cur_path(char *scan_path);
g_mutex_unlock(&data_mutex2);
}
-static int __msc_check_stop_status(int scan_type, const char *start_path, int pid)
+static int __msc_check_stop_status(ms_msg_type_e msg_type, const char *start_path, int pid)
{
int ret = MS_MEDIA_ERR_NONE;
if (_msc_is_power_off())
return MS_MEDIA_ERR_SCANNER_FORCE_STOP;
- if (scan_type == MS_MSG_DIRECTORY_SCANNING || scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
+ if (msg_type == MS_MSG_DIRECTORY_SCANNING || msg_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) {
g_mutex_lock(&scan_req_mutex2);
/* check cancel path */
//MS_DBG_ERR("__msc_check_stop_status...");
g_mutex_unlock(&scan_req_mutex2);
}
- if (scan_type == MS_MSG_STORAGE_ALL || scan_type == MS_MSG_STORAGE_PARTIAL) {
+ if (msg_type == MS_MSG_STORAGE_ALL || msg_type == MS_MSG_STORAGE_PARTIAL) {
g_mutex_lock(&blocked_mutex2);
/* check cancel path */
if (g_blocked_path2 != NULL) {
return ret;
}
-static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, char *start_path, int scan_type, int pid, uid_t uid)
+static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, char *start_path, ms_msg_type_e msg_type, int pid, uid_t uid)
{
GPtrArray *dir_array = NULL;
int ret = MS_MEDIA_ERR_NONE;
char *new_path = NULL;
char *current_path = NULL;
char path[MS_FILE_PATH_LEN_MAX] = {0, };
- bool is_recursive = (scan_type == MS_MSG_DIRECTORY_SCANNING);
+ bool is_recursive = (msg_type == MS_MSG_DIRECTORY_SCANNING);
char *new_start_path = NULL;
int scan_count = 0;
MS_DBG_SWARN("ms_insert_folder insert path[%s]", new_start_path);
} else {
if (ms_set_folder_validity(handle, storage_id, new_start_path, MS_INVALID, is_recursive, uid) != MS_MEDIA_ERR_NONE)
- MS_DBG_ERR("set_folder_validity failed [%d] ", scan_type);
+ MS_DBG_ERR("set_folder_validity failed [%d] ", msg_type);
}
while (dir_array->len != 0) {
- ret = __msc_check_stop_status(scan_type, new_start_path, pid);
+ ret = __msc_check_stop_status(msg_type, new_start_path, pid);
if (ret != MS_MEDIA_ERR_NONE) {
if (is_recursive)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
continue;
}
- ret = msc_check_db_size(uid, scan_type);
+ ret = msc_check_db_size(uid, msg_type);
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
ret = MS_MEDIA_ERR_NONE;
usleep(SCAN_SLEEP_TIME);
}
- ret = __msc_check_stop_status(scan_type, new_start_path, pid);
+ ret = __msc_check_stop_status(msg_type, new_start_path, pid);
if (ret != MS_MEDIA_ERR_NONE) {
if (is_recursive)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
goto STOP_SCAN;
}
- ret = msc_check_db_size(uid, scan_type);
+ ret = msc_check_db_size(uid, msg_type);
if (ret != MS_MEDIA_ERR_NONE) {
if (ret == MS_MEDIA_ERR_DB_FULL_FAIL)
ret = MS_MEDIA_ERR_NONE;
if (scan_count >= MAX_SCAN_COUNT) {
scan_count = 0;
- ret = __msc_check_stop_status(scan_type, new_start_path, pid);
+ ret = __msc_check_stop_status(msg_type, new_start_path, pid);
if (ret == MS_MEDIA_ERR_NONE) {
- msc_insert_exactor_request(scan_type, false, storage_id, current_path, pid, uid, MS_ITEM_UPDATE);
+ msc_insert_exactor_request(msg_type, false, storage_id, current_path, pid, uid, MS_ITEM_UPDATE);
} else {
if (is_recursive)
ms_change_validity_item_batch(handle, storage_id, new_start_path, 1, 2, uid);
}
}
} else {
- if (scan_type == MS_MSG_DIRECTORY_SCANNING) {
+ if (msg_type == MS_MSG_DIRECTORY_SCANNING) {
new_path = g_strdup(path);
g_ptr_array_add(dir_array, new_path);
}
}
}
- if (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE)
+ if (msg_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE)
ms_update_folder_time(handle, storage_id, current_path, uid);
ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_DONE, uid);
return ret;
}
-static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, char *start_path, int scan_type, int pid, uid_t uid)
+static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, char *start_path, ms_msg_type_e msg_type, int pid, uid_t uid)
{
GPtrArray *dir_array = NULL;
int ret = MS_MEDIA_ERR_NONE;
if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("insert folder failed");
- scan_function = (scan_type == MS_MSG_STORAGE_ALL) ? ms_scan_item_batch : ms_validate_item;
+ scan_function = (msg_type == MS_MSG_STORAGE_ALL) ? ms_scan_item_batch : ms_validate_item;
ms_register_end(uid);
while (dir_array->len != 0) {
- ret = __msc_check_stop_status(scan_type, new_start_path, pid);
+ ret = __msc_check_stop_status(msg_type, new_start_path, pid);
if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
continue;
}
- ret = msc_check_db_size(uid, scan_type);
+ ret = msc_check_db_size(uid, msg_type);
if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
usleep(SCAN_SLEEP_TIME);
}
- ret = __msc_check_stop_status(scan_type, new_start_path, pid);
+ ret = __msc_check_stop_status(msg_type, new_start_path, pid);
if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
- ret = msc_check_db_size(uid, scan_type);
+ ret = msc_check_db_size(uid, msg_type);
if (ret != MS_MEDIA_ERR_NONE)
goto STOP_SCAN;
ret = scan_function(handle, storage_id, path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("failed to update db : %d", scan_type);
+ MS_DBG_ERR("failed to update db : %d", msg_type);
continue;
} else {
++scan_count;
if (scan_count >= MAX_SCAN_COUNT) {
scan_count = 0;
- msc_insert_exactor_request(scan_type, false, storage_id, current_path, 0, uid, MS_ITEM_UPDATE);
+ msc_insert_exactor_request(msg_type, false, storage_id, current_path, 0, uid, MS_ITEM_UPDATE);
}
}
} else {
static int __msc_db_update(sqlite3 *handle, const char *storage_id, const ms_comm_msg_s * scan_data)
{
- int scan_type;
+ ms_msg_type_e msg_type;
int err = MS_MEDIA_ERR_NONE;
char *start_path = NULL;
- scan_type = scan_data->msg_type;
+ msg_type = scan_data->msg_type;
start_path = g_strdup(scan_data->msg);
- if (scan_type != MS_MSG_STORAGE_INVALID) {
+ if (msg_type != MS_MSG_STORAGE_INVALID) {
MS_DBG_INFO("INSERT");
- if (scan_type == MS_MSG_STORAGE_ALL)
+ if (msg_type == MS_MSG_STORAGE_ALL)
err = __msc_dir_scan(handle, storage_id, start_path, false, true, scan_data->uid);
else
err = __msc_dir_scan(handle, storage_id, start_path, true, true, scan_data->uid);