Modify scanner progress 75/206175/2
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 15 May 2019 02:05:36 +0000 (11:05 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Wed, 15 May 2019 06:30:30 +0000 (06:30 +0000)
If the modified time of the database and the file system are different,
use UPDATE instead of DELETE/INSERT.

Change-Id: Ibaa7a66a203fbacaaeb115d5744b98d70e3bcd9a
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/include/media-common-db-svc.h
src/common/media-common-db-svc.c

index 073377f..5560b73 100755 (executable)
@@ -95,6 +95,7 @@ typedef int (*GET_EXTRACT_LIST)(sqlite3*, const char*, int, int, const char*, in
 typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3*, const char*, int, void *);
 typedef int (*QUERY_DO_UPDATE_LIST)(sqlite3*);
 typedef int (*GET_MEDIA_TYPE)(const char *, int *);
+typedef int (*REFRESH_ITEM)(sqlite3 *, const char *, const char *, uid_t);
 
 int ms_load_functions(void);
 void ms_unload_functions(void);
index 6c2a221..ce00de6 100755 (executable)
@@ -81,6 +81,7 @@ enum func_list {
        eGET_EXTRACT_LIST,
        eUPDATE_ONE_EXTRACT_ITEM,
        eQUERY_DO_UPDATE_LIST,
+       eREFRESH_ITEM,
        eFUNC_MAX
 };
 
@@ -179,6 +180,7 @@ int ms_load_functions(void)
                "get_extract_list",
                "update_one_extract_item",
                "query_do_update_list",
+               "refresh_item",
                };
        /*init array for adding name of so*/
        so_array = g_array_new(FALSE, FALSE, sizeof(char*));
@@ -395,9 +397,8 @@ int ms_validate_item(sqlite3 *handle, const char *storage_id, const char *path,
                                MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Error : %s [%s]", g_array_index(so_array, char*, lib_index), path);
                        } else {
                                /* the file has same name but it is changed, so we have to update DB */
-                               ret = ((DELETE_ITEM)func_array[lib_index][eDELETE_ITEM])(handle, storage_id, path, uid); /*dlopen*/
+                               ret = ((REFRESH_ITEM)func_array[lib_index][eREFRESH_ITEM])(handle, storage_id, path, uid); /*dlopen*/
                                MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Error : %s [%s]", g_array_index(so_array, char*, lib_index), path);
-                               ret = ms_insert_item_batch(handle, storage_id, path, uid);
                        }
                } else {
                        MS_DBG_ERR("check_item_exist failed [%d]", ret);
@@ -425,9 +426,8 @@ int ms_scan_validate_item(sqlite3 *handle, const char *storage_id, const char *p
                                MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Error : %s [%s]", g_array_index(so_array, char*, lib_index), path);
                        } else {
                                /* the file has same name but it is changed, so we have to update DB */
-                               ret = ((DELETE_ITEM)func_array[lib_index][eDELETE_ITEM])(handle, storage_id, path, uid); /*dlopen*/
+                               ret = ((REFRESH_ITEM)func_array[lib_index][eREFRESH_ITEM])(handle, storage_id, path, uid); /*dlopen*/
                                MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Error : %s [%s]", g_array_index(so_array, char*, lib_index), path);
-                               ret = ms_scan_item_batch(handle, storage_id, path, uid);
                        }
                } else {
                        MS_DBG_ERR("check_item_exist failed [%d]", ret);