if(value == 1 || value == 2)
{
MS_DBG_WARN("POWER_OFF_REASON_FACTORY_RESET or SERVICE RESET");
-
+
ms_reset_mediadb(uid);
if(!ms_config_set_int(MS_VCONF_KEY_RESET_STATUS, 0))
{
int ret = MS_MEDIA_ERR_NONE;
int disc_state = 0;
+ int validity = 0;
char *disc_type = NULL;
char *disc_path = NULL;
char *valid_type = "data";
ms_dir_scan_type_t scan_type = MS_SCAN_PART;
uid_t uid = MEDIA_DEFAULT_UID;
- char storage_path[11] = {0,};
+ char mnt_path[11] = {0,};
+ char *storage_path = NULL;
void **handle = NULL;
/*check disc type */
}
MS_DBG("[disc path] %s", disc_path);
- memset(storage_path, 0x0, sizeof(storage_path));
- strncpy(storage_path, disc_path, sizeof(storage_path)-1);
+ memset(mnt_path, 0x0, sizeof(mnt_path));
+ strncpy(mnt_path, disc_path, sizeof(mnt_path)-1);
if (disc_state == 1) {
MS_DBG_WARN("[DISC INSERTED][%s]",disc_type);
-
- MS_DBG_WARN("MOUNT PATH [%s]", storage_path);
- ret = ms_insert_storage(handle, DATADISC_STORAGE_ID, NULL, storage_path, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_insert_storage failed");
+ MS_DBG_WARN("MOUNT PATH [%s]", mnt_path);
+
+ /* update storage information into media DB */
+ ret = ms_check_storage(handle, DATADISC_STORAGE_ID, NULL, &storage_path, &validity);
+ if (ret == 0) {
+ ms_set_storage_validity(handle, DATADISC_STORAGE_ID, 1, uid);
+ if (ms_set_storage_scan_status(handle, DATADISC_STORAGE_ID, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_set_storage_scan_status failed");
+ goto END;
+ }
+
+ MS_DBG_WARN("init storage data in DB");
+ /* update storage_id table set validity=0 first */
+ ms_validaty_change_all_items(handle, DATADISC_STORAGE_ID, MS_STORAGE_EXTERNAL, false, uid);
+ /*update folder table set validity = 0*/
+ ms_set_folder_validity(handle, DATADISC_STORAGE_ID, mnt_path, MS_INVALID, TRUE, uid);
+ /* update folder table set scan_status=0 first */
+ ms_set_folder_scan_status(handle, DATADISC_STORAGE_ID, NULL, MS_DIR_SCAN_NONE, uid);
+ MS_DBG_WARN("init storage data in DB end");
+
} else {
- ms_send_storage_scan_request(storage_path, DATADISC_STORAGE_ID, scan_type, uid);
+ ret = ms_insert_storage(handle, DATADISC_STORAGE_ID, NULL, mnt_path, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ MS_DBG_ERR("ms_insert_storage failed");
+ goto END;
+ }
}
+
+ ms_send_storage_scan_request(mnt_path, DATADISC_STORAGE_ID, scan_type, uid);
} else {
MS_DBG_WARN("[DISC REMOVED]");
ms_set_storage_validity(handle, DATADISC_STORAGE_ID, 0, uid);
- ms_set_folder_validity(handle, DATADISC_STORAGE_ID, storage_path, false, true, uid);
+ ms_set_folder_validity(handle, DATADISC_STORAGE_ID, mnt_path, false, true, uid);
ms_validaty_change_all_items(handle, DATADISC_STORAGE_ID, MS_STORAGE_EXTERNAL_USB, false, uid);
}
ms_connect_db(&handle, uid);
- /* update storage information into media DB */
+ /* update storage information into media DB */
ret = ms_check_storage(handle, DATADISC_STORAGE_ID, NULL, &storage_path, &validity);
if (ret == 0) {
ms_set_storage_validity(handle, DATADISC_STORAGE_ID, 1, uid);
if (ms_set_storage_scan_status(handle, DATADISC_STORAGE_ID, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("ms_set_storage_scan_status failed");
+ goto END;
}
MS_DBG_WARN("init storage data in DB");