sqlite3 *handle = NULL;
ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
int scan_type;
- char *update_path = NULL;
uid_t uid = MEDIA_DEFAULT_UID;
while (1) {
uid = scan_data->uid;
- /*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");
goto NEXT;
}
- update_path = g_strdup(scan_data->msg);
-
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_set_storage_scan_status(handle, scan_data->storage_id, MEDIA_SCAN_PROCESSING, uid);
- /*start db updating */
ms_set_db_status(MS_DB_UPDATING, storage_type);
if (scan_type != MS_MSG_STORAGE_INVALID)
ms_batch_commit_enable(false, 0);
if (scan_type == MS_MSG_STORAGE_ALL) {
- /* Delete all data before full scanning */
if (ms_delete_invalid_items(handle, scan_data->storage_id, uid) != MS_MEDIA_ERR_NONE)
MS_DBG_ERR("ms_delete_invalid_items fails");
}
ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
- /*call for bundle commit*/
if (scan_type != MS_MSG_STORAGE_INVALID)
ms_batch_commit_disable(uid);
if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE) {
- /*delete invalid folder first, then delete invalid item, avoid to folder was deleted but item not when unmount*/
ms_delete_invalid_folder(scan_data->storage_id, uid);
ms_delete_invalid_items(handle, scan_data->storage_id, uid);
}
- /* send notification */
- /*ms_send_dir_update_noti(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);
- /*set vconf key mmc loading for indicator */
ms_set_db_status(MS_DB_STOPPED, storage_type);
} else {
ms_set_storage_scan_status(handle, scan_data->storage_id, MEDIA_SCAN_COMPLETE, uid);
- /*set vconf key mmc loading for indicator */
ms_set_db_status(MS_DB_UPDATED, storage_type);
}
NEXT:
__msc_del_blocked_path();
- g_free(update_path);
- update_path = NULL;
-
if (_msc_is_power_off())
goto _POWEROFF;
- /*disconnect from media db*/
ms_disconnect_db(handle);
- /*Active flush */
malloc_trim(0);
scan_data->msg_type = MS_MSG_SCANNER_COMPLETE;
MS_DBG_WARN("STORAGE SCAN END[%d]", ret);
usleep(SCAN_SLEEP_TIME);
- } /*thread while*/
+ }
_POWEROFF:
g_free(scan_data);