Add logic for check db when external storage is inserted. 43/58543/5 submit/tizen/20160202.024652
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 1 Feb 2016 23:36:59 +0000 (08:36 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Tue, 2 Feb 2016 01:56:46 +0000 (10:56 +0900)
Change-Id: I51c9e8ff907e7c811b83da3b8d32a20a4daa2997
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/server/media-server-device-block.c

index 0ea134d..84eb271 100755 (executable)
@@ -62,6 +62,7 @@ int ms_usb_insert_handler(const char *mount_path, const char *mount_uuid)
        char *storage_path = NULL;
        void **handle = NULL;
        int validity = 0;
+       bool scan = false;
        uid_t uid;
        ms_dir_scan_type_t scan_type = MS_SCAN_ALL;
 
@@ -75,6 +76,13 @@ int ms_usb_insert_handler(const char *mount_path, const char *mount_uuid)
        ms_connect_db(&handle, uid);
 
        if (mount_path != NULL && mount_uuid != NULL) {
+               /*CHECK DB HERE */
+               ret = ms_check_db_upgrade(handle, &scan, uid);
+               if (ret != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("ms_check_db_upgrade failed");
+                       goto ERROR;
+               }
+
                /* update storage information into media DB */
                ret = ms_check_storage(handle, mount_uuid, NULL, &storage_path, &validity);
                if (ret == 0) {
@@ -96,6 +104,10 @@ int ms_usb_insert_handler(const char *mount_path, const char *mount_uuid)
                } else {
                        /* there is no information of this storage in Media DB */
                        ret = ms_insert_storage(handle, mount_uuid, NULL, mount_path, uid);
+                       if (ret != MS_MEDIA_ERR_NONE) {
+                               MS_DBG_ERR("ms_insert_storage failed");
+                               goto ERROR;
+                       }
                }
 
                /* request to update media db */
@@ -219,6 +231,7 @@ int ms_mmc_insert_handler(const char *mount_path)
        bool info_exist = FALSE;
        char *cid = NULL;
        uid_t uid;
+       bool scan = false;
 
        void **db_handle = NULL;
 
@@ -240,6 +253,15 @@ int ms_mmc_insert_handler(const char *mount_path)
        ms_present_mmc_status(MS_SDCARD_INSERTED);
 
        ms_get_mmc_id(&cid);
+       /* CHECK DB HERE!! */
+       ret = ms_check_db_upgrade(db_handle, &scan, uid);
+       if (ret != MS_MEDIA_ERR_NONE) {
+               MS_DBG_ERR("ms_check_db_upgrade failed [%d]", ret);
+               ms_disconnect_db(&db_handle);
+               ms_unload_functions();
+               return MS_MEDIA_ERR_INTERNAL;
+       }
+
        __ms_get_mmc_info(db_handle, &storage_name, &storage_path, &validity, &info_exist);
 
        if (info_exist == TRUE) {