diff options
author | Yong Yeon Kim <yy9875.kim@samsung.com> | 2013-09-16 16:18:19 +0900 |
---|---|---|
committer | Yong Yeon Kim <yy9875.kim@samsung.com> | 2013-09-16 16:18:19 +0900 |
commit | a509e36c8738b342411bc17278501dbe49de6c13 (patch) | |
tree | c5e4723605512af7ab9167f18cbe5a6d25bb5a5a | |
parent | d45e77f2dcb59fd0b6e83d459615f902c5a6c715 (diff) | |
download | media-server-a509e36c8738b342411bc17278501dbe49de6c13.tar.gz media-server-a509e36c8738b342411bc17278501dbe49de6c13.tar.bz2 media-server-a509e36c8738b342411bc17278501dbe49de6c13.zip |
fix N_SE-51921
-rwxr-xr-x | packaging/media-server.spec | 2 | ||||
-rwxr-xr-x | src/scanner/include/media-scanner-db-svc.h | 6 | ||||
-rwxr-xr-x | src/scanner/media-scanner-db-svc.c | 69 |
3 files changed, 58 insertions, 19 deletions
diff --git a/packaging/media-server.spec b/packaging/media-server.spec index 1c83402..955043a 100755 --- a/packaging/media-server.spec +++ b/packaging/media-server.spec @@ -1,6 +1,6 @@ Name: media-server Summary: File manager service server. -Version: 0.2.55 +Version: 0.2.56 Release: 1 Group: utils License: Apache License, Version 2.0 diff --git a/src/scanner/include/media-scanner-db-svc.h b/src/scanner/include/media-scanner-db-svc.h index 1e0df36..cc073ec 100755 --- a/src/scanner/include/media-scanner-db-svc.h +++ b/src/scanner/include/media-scanner-db-svc.h @@ -35,10 +35,11 @@ typedef int (*CHECK_ITEM)(const char*, char **); typedef int (*CONNECT)(void**, char **); typedef int (*DISCONNECT)(void*, char **); -typedef int (*CHECK_ITEM_EXIST)(void*, const char*, int, char **); +typedef int (*CHECK_ITEM_EXIST)(void*, const char*, bool*, char **); typedef int (*INSERT_ITEM_BEGIN)(void*, int, int, int, char **); typedef int (*INSERT_ITEM_END)(void*, char **); typedef int (*INSERT_ITEM)(void*, const char*, int, char **); +typedef int (*INSERT_ITEM_IMMEDIATELY)(void*, const char*, int, char **); typedef int (*SET_ALL_STORAGE_ITEMS_VALIDITY)(void*, int, int, char **); typedef int (*SET_ITEM_VALIDITY_BEGIN)(void*, int, char **); typedef int (*SET_ITEM_VALIDITY_END)(void*, char **); @@ -52,6 +53,7 @@ typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(void*, const char*, char**); typedef int (*INSERT_BURST_ITEM)(void *, const char *, int , char **); typedef int (*SEND_DIR_UPDATE_NOTI)(void *, const char *, char **); typedef int (*COUNT_DELETE_ITEMS_IN_FOLDER)(void *, const char *, int *, char **); +typedef int (*DELETE_ITEM)(void *, const char *, char **); int msc_load_functions(void); @@ -95,6 +97,8 @@ msc_send_dir_update_noti(void **handle, const char*path); int msc_count_delete_items_in_folder(void **handle, const char*path, int *count); +int +msc_insert_item_immediately(void **handle, const char *path); /**************************************************************************************************** FOR BULK COMMIT *****************************************************************************************************/ diff --git a/src/scanner/media-scanner-db-svc.c b/src/scanner/media-scanner-db-svc.c index 2338ba4..0da8cb3 100755 --- a/src/scanner/media-scanner-db-svc.c +++ b/src/scanner/media-scanner-db-svc.c @@ -57,6 +57,7 @@ enum func_list { eINSERT_BEGIN, eINSERT_END, eINSERT_BATCH, + eINSERT_ITEM_IMMEDIATELY, eSET_ALL_VALIDITY, eSET_VALIDITY_BEGIN, eSET_VALIDITY_END, @@ -70,6 +71,7 @@ enum func_list { eINSERT_BURST, eSEND_DIR_UPDATE_NOTI, eCOUNT_DELETE_ITEMS_IN_FOLDER, + eDELETE_ITEM, eFUNC_MAX }; @@ -150,6 +152,7 @@ msc_load_functions(void) "insert_item_begin", "insert_item_end", "insert_item", + "insert_item_immediately", "set_all_storage_items_validity", "set_item_validity_begin", "set_item_validity_end", @@ -163,6 +166,7 @@ msc_load_functions(void) "insert_burst_item", "send_dir_update_noti", "count_delete_items_in_folder", + "delete_item", }; /*init array for adding name of so*/ so_array = g_array_new(FALSE, FALSE, sizeof(char*)); @@ -324,36 +328,44 @@ msc_validate_item(void **handle, const char *path) int res = MS_MEDIA_ERR_NONE; int ret; char *err_msg = NULL; - ms_storage_type_t storage_type; - - storage_type = ms_get_storage_type_by_full(path); + bool modified = FALSE; for (lib_index = 0; lib_index < lib_num; lib_index++) { - if (!_msc_check_category(path, lib_index)) { - /*check exist in Media DB, If file is not exist, insert data in DB. */ - ret = ((CHECK_ITEM_EXIST)func_array[lib_index][eEXIST])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/ + /*check exist in Media DB, If file is not exist, insert data in DB. */ + ret = ((CHECK_ITEM_EXIST)func_array[lib_index][eEXIST])(handle[lib_index], path, &modified, &err_msg); /*dlopen*/ + if (ret != 0) { + MS_SAFE_FREE(err_msg); + ret = msc_insert_item_batch(handle, path); if (ret != 0) { - MS_SAFE_FREE(err_msg); - - ret = ((INSERT_ITEM)func_array[lib_index][eINSERT_BATCH])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/ + res = MS_MEDIA_ERR_DB_INSERT_FAIL; + } else { + insert_count++; + } + } else { + if (modified == FALSE) { + /*if meta data of file exist, change valid field to "1" */ + ret = ((SET_ITEM_VALIDITY)func_array[lib_index][eSET_VALIDITY])(handle[lib_index], path, true, true, &err_msg); /*dlopen*/ if (ret != 0) { MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path); MS_SAFE_FREE(err_msg); - res = MS_MEDIA_ERR_DB_INSERT_FAIL; - } else { - insert_count++; + res = MS_MEDIA_ERR_DB_UPDATE_FAIL; } } else { - /*if meta data of file exist, change valid field to "1" */ - ret = ((SET_ITEM_VALIDITY)func_array[lib_index][eSET_VALIDITY])(handle[lib_index], path, true, true, &err_msg); /*dlopen*/ + /* 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[lib_index], path, &err_msg); /*dlopen*/ if (ret != 0) { MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path); MS_SAFE_FREE(err_msg); - res = MS_MEDIA_ERR_DB_UPDATE_FAIL; + res = MS_MEDIA_ERR_DB_DELETE_FAIL; + } else { + ret = msc_insert_item_immediately(handle, path); + if (ret != 0) { + res = MS_MEDIA_ERR_DB_INSERT_FAIL; + } else { + insert_count++; + } } } - } else { - MSC_DBG_ERR("check category failed [%s]", path); } } @@ -408,6 +420,29 @@ msc_insert_item_batch(void **handle, const char *path) } int +msc_insert_item_immediately(void **handle, const char *path) +{ + int lib_index; + int res = MS_MEDIA_ERR_NONE; + int ret; + char *err_msg = NULL; + ms_storage_type_t storage_type; + + storage_type = ms_get_storage_type_by_full(path); + + for (lib_index = 0; lib_index < lib_num; lib_index++) { + ret = ((INSERT_ITEM_IMMEDIATELY)func_array[lib_index][eINSERT_ITEM_IMMEDIATELY])(handle[lib_index], path, storage_type, &err_msg); /*dlopen*/ + if (ret != 0) { + MSC_DBG_ERR("error : %s [%s] %s", g_array_index(so_array, char*, lib_index), err_msg, path); + MS_SAFE_FREE(err_msg); + res = MS_MEDIA_ERR_DB_INSERT_FAIL; + } + } + + return res; +} + +int msc_insert_burst_item(void **handle, const char *path) { int lib_index; |