static int __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;
- unsigned int next_pos = 0;
+ size_t next_pos = ms_user_get_root_length(path, uid);
char *next = NULL;
char *dir_path = NULL;
- char *internal_path = NULL;
-
- if (g_str_has_prefix(path, tzplatform_getenv(TZ_SYS_STORAGE))) {
- next_pos = strlen(tzplatform_getenv(TZ_SYS_STORAGE)) + 1;
- } else {
- ret = ms_user_get_internal_root_path(uid, &internal_path);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get root path");
-
- next_pos = strlen(internal_path);
- g_free(internal_path);
- }
do {
next = strstr(path + next_pos, "/");