return _media_svc_sql_query(q, uid);
}
-static int __media_svc_append_parent_folder(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, uid_t uid)
+static void __media_svc_append_parent_folder(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, uid_t uid)
{
- int ret = MS_MEDIA_ERR_NONE;
size_t next_pos = ms_user_get_root_length(path, uid);
char *next = NULL;
char *dir_path = NULL;
dir_path = g_strdup(path);
}
- ret = _media_svc_check_folder_by_path(handle, dir_path);
- if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- ret = __media_svc_append_folder(is_direct, storage_id, dir_path, uid);
- if (ret != MS_MEDIA_ERR_NONE)
+ if (_media_svc_check_folder_by_path(handle, dir_path) == MS_MEDIA_ERR_DB_NO_RECORD) {
+ if (__media_svc_append_folder(is_direct, storage_id, dir_path, uid) != MS_MEDIA_ERR_NONE)
media_svc_error("__media_svc_append_folder is failed");
else
media_svc_sec_debug("Append new folder path[%s]", dir_path);
g_free(dir_path);
} while (next);
-
- return MS_MEDIA_ERR_NONE;
}
int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, long long int *folder_id, uid_t uid)
ret = __media_svc_get_folder_id(handle, dir_path, folder_id);
if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- ret = __media_svc_append_parent_folder(handle, is_direct, storage_id, dir_path, uid);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "failed to append parent folder");
-
+ __media_svc_append_parent_folder(handle, is_direct, storage_id, dir_path, uid);
return __media_svc_get_folder_id(handle, dir_path, folder_id);
}
int _media_svc_append_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
{
- if (_media_svc_check_folder_by_path(handle, path) == MS_MEDIA_ERR_DB_NO_RECORD)
- return __media_svc_append_parent_folder(handle, true, storage_id, path, uid);
+ if (_media_svc_check_folder_by_path(handle, path) == MS_MEDIA_ERR_DB_NO_RECORD) {
+ __media_svc_append_parent_folder(handle, true, storage_id, path, uid);
+ return MS_MEDIA_ERR_NONE;
+ }
return _media_svc_set_folder_validity(true, path, 1, false, uid);
}