This patch changes media-scanner-v2 to write directly to media.db.
It makes better performance than bulk insert through IPC.
Change-Id: Ia91b44d8707b32d4c347c1b152b5225da6dbad17
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
typedef int (*SET_STORAGE_SCAN_STATUS)(sqlite3 *, const char *, int, uid_t);
typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, int, uid_t);
typedef int (*SET_FOLDER_VALIDITY)(sqlite3 *, const char *, const char *, int, bool, uid_t);
-typedef int (*INSERT_FOLDER_BEGIN)(int);
-typedef int (*INSERT_FOLDER_END)(uid_t);
typedef int (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, int, uid_t);
typedef int (*GET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int *);
typedef int (*SET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int, uid_t);
void ms_register_end(uid_t uid);
void ms_validate_start(void);
void ms_validate_end(uid_t uid);
-void ms_insert_folder_start(void);
-void ms_insert_folder_end(uid_t uid);
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_update_one_extract_item(sqlite3 *handle, const char* storage_id, int storage_type, void* data);
eSET_STORAGE_SCAN_STATUS,
eINSERT_FOLDER,
eSET_FOLDER_VALIDITY,
- eINSERT_FOLDER_BEGIN,
- eINSERT_FOLDER_END,
eGET_FOLDER_SCAN_STATUS,
eSET_FOLDER_SCAN_STATUS,
eCHECK_FOLDER_MODIFIED,
"set_storage_scan_status",
"insert_folder",
"set_folder_validity",
- "insert_folder_begin",
- "insert_folder_end",
"get_folder_scan_status",
"set_folder_scan_status",
"check_folder_modified",
{
int ret = MS_MEDIA_ERR_NONE;
- /*Lock mutex for openning db*/
g_mutex_lock(&db_mutex);
ret = media_db_connect(handle, uid, false);
MS_DBG_ERR("SET_ITEM_VALIDITY_END failed [%d]", ret);
}
-void ms_insert_folder_start(void)
-{
- int ret = MS_MEDIA_ERR_NONE;
-
- ret = ((INSERT_FOLDER_BEGIN)func_array[eINSERT_FOLDER_BEGIN])(MSC_REGISTER_COUNT);/*dlopen*/
- if (ret != MS_MEDIA_ERR_NONE)
- MS_DBG_ERR("INSERT_FOLDER_BEGIN failed [%d]", ret);
-}
-
-void ms_insert_folder_end(uid_t uid)
-{
- int ret = MS_MEDIA_ERR_NONE;
-
- ret = ((INSERT_FOLDER_END)func_array[eINSERT_FOLDER_END])(uid);/*dlopen*/
- if (ret != MS_MEDIA_ERR_NONE)
- MS_DBG_ERR("INSERT_FOLDER_END failed [%d]", ret);
-}
-
int ms_get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *scan_status)
{
int ret = MS_MEDIA_ERR_NONE;
//MS_DBG_ERR("new start path [%s]", new_start_path);
g_array_append_val(dir_array, start_path);
- ms_insert_folder_end(uid);
is_recursive = (scan_type == MS_MSG_DIRECTORY_SCANNING_NON_RECURSIVE) ? false : true;
goto STOP_SCAN;
}
- ms_insert_folder_start();
ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_PROCESSING, uid);
sleep_count = 0;
}
}
- ms_insert_folder_end(uid);
ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_DONE, uid);
if (fd != -1) {
STOP_SCAN:
MS_DBG_ERR("stop folder scan...");
- ms_insert_folder_end(uid);
ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
MS_SAFE_FREE(current_path);
new_start_path = g_strdup(start_path);
g_array_append_val(dir_array, start_path);
- ms_insert_folder_end(uid);
if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("insert folder failed");
}
}
- ms_insert_folder_start();
ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_PROCESSING, uid);
sleep_count = 0;
}
}
- ms_insert_folder_end(uid);
/*commit to db before set scan done, fix timing issue storage scan, then folder scan for same folder*/
ms_batch_commit_disable(true, true, uid);
ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_DONE, uid);
goto EXIT;
STOP_SCAN:
- ms_insert_folder_end(uid);
if (current_path != NULL)
ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_STOP, uid);
MS_SAFE_FREE(current_path);