static void __media_info_face_completed_cb(int error, const int face_count, void *user_data);
static int __media_info_insert_batch(media_batch_insert_e insert_type, const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data);
static int __media_info_set_str_data(media_info_h media, media_info_item_e data_type, const char *str_data);
+static int __media_info_check_file_validity(const char *path);
static int __media_info_get_media_path_by_id_from_db(const char *media_id, char **path)
{
if (STRING_VALID(path_array[idx])) {
int size = strlen(path_array[idx]);
- ret = _media_util_check_file_exist(path_array[idx]);
+ ret = __media_info_check_file_validity(path_array[idx]);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
fclose(fp);
if (unlink(list_path) < 0)
return ret;
}
+static int __media_info_check_file_validity(const char *path)
+{
+ bool ignore = FALSE;
+ char *folder_path = NULL;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
+
+ ret = _media_util_check_ignore_file(path, &ignore);
+ media_content_retvm_if(ignore == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid ignore path");
+
+ ret = _media_util_check_file_exist(path);
+ media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "invalid path");
+
+ folder_path = g_path_get_dirname(path);
+ ret = _media_util_check_ignore_dir(folder_path, &ignore);
+ SAFE_FREE(folder_path);
+ media_content_retvm_if(ignore == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
{
media_info_s *_media = (media_info_s*)media;
int media_info_insert_to_db(const char *path, media_info_h *info)
{
- bool ignore_file = FALSE;
- bool ignore_dir = FALSE;
- char *folder_path = NULL;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
char repl_path[MAX_PATH_LEN] = {0, };
int ret = MEDIA_CONTENT_ERROR_NONE;
ret = _media_content_replace_path(path, repl_path);
media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = _media_util_check_ignore_file(repl_path, &ignore_file);
- media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
-
- ret = _media_util_check_file_exist(repl_path);
+ ret = __media_info_check_file_validity(repl_path);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- folder_path = g_path_get_dirname(repl_path);
- ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
- SAFE_FREE(folder_path);
-
- media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
-
memset(storage_id, 0x00, sizeof(storage_id));
ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
return ret;
}
-int media_info_insert_batch_to_db(
- const char **path_array,
- unsigned int array_length,
- media_insert_completed_cb completed_cb,
- void *user_data)
+int media_info_insert_batch_to_db(const char **path_array, unsigned int array_length, media_insert_completed_cb completed_cb, void *user_data)
{
char **repl_path_array = NULL;
int idx = 0;
int media_info_move_to_db(media_info_h media, const char* dst_path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- bool ignore_file = FALSE;
- bool ignore_dir = FALSE;
- char *folder_path = NULL;
media_svc_storage_type_e src_storage_type = 0;
media_svc_storage_type_e dst_storage_type = 0;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
media_info_s *_media = (media_info_s*)media;
- ret = _media_util_check_ignore_file(repl_path, &ignore_file);
- media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
ret = _media_content_replace_path(_media->file_path, org_repl_path);
media_content_retvm_if(!STRING_VALID(org_repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = _media_util_check_file_exist(repl_path);
+ ret = __media_info_check_file_validity(repl_path);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- folder_path = g_path_get_dirname(repl_path);
- ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
- SAFE_FREE(folder_path);
-
- media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
-
ret = media_svc_get_storage_type(org_repl_path, &src_storage_type, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
int ret = MEDIA_CONTENT_ERROR_NONE;
char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
media_svc_storage_type_e storage_type = 0;
- bool ignore_file = FALSE;
char repl_path[MAX_PATH_LEN] = {0, };
media_content_warn("DEPRECATION WARNING: media_info_create() is deprecated and will be removed from next release. Use media_info_insert_to_db() instead.");
ret = _media_content_replace_path(path, repl_path);
media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- ret = _media_util_check_ignore_file(repl_path, &ignore_file);
- media_content_retvm_if(ignore_file == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
-
memset(storage_id, 0x00, sizeof(storage_id));
- bool ignore_dir = FALSE;
- char *folder_path = NULL;
-
- ret = _media_util_check_file_exist(repl_path);
+ ret = __media_info_check_file_validity(repl_path);
media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- folder_path = g_path_get_dirname(repl_path);
- ret = _media_util_check_ignore_dir(folder_path, &ignore_dir);
- SAFE_FREE(folder_path);
- media_content_retvm_if(ignore_dir == TRUE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
-
ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
if (ret != MS_MEDIA_ERR_NONE) {
media_content_error("media_svc_get_storage_id failed : %d", ret);