From: Minje Ahn Date: Thu, 5 Mar 2020 07:09:42 +0000 (+0900) Subject: Improve function to get storage id X-Git-Tag: submit/tizen/20200306.013725^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F226758%2F3;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Improve function to get storage id Change-Id: I2e52a2b5a86f58fe2e921bccbd192754b3915bdd Signed-off-by: Minje Ahn --- diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index 9903a71..127edc0 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -161,9 +161,6 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage int ret = MS_MEDIA_ERR_NONE; sqlite3_stmt *sql_stmt = NULL; char *sql = NULL; - char *storage_path = NULL; - char *remain_path = NULL; - int remain_len = 0; char *internal_path = NULL; media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); @@ -179,16 +176,9 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage SAFE_FREE(internal_path); - remain_path = strstr(path + (STRING_VALID(MEDIA_ROOT_PATH_USB) ? strlen(MEDIA_ROOT_PATH_USB) : 0) + 1, "/"); - if (remain_path != NULL) - remain_len = strlen(remain_path); - - storage_path = strndup(path, strlen(path) - remain_len); - - sql = sqlite3_mprintf("SELECT storage_id FROM '%q' WHERE validity=1 AND storage_path = '%q'", MEDIA_SVC_DB_TABLE_STORAGE, storage_path); + sql = sqlite3_mprintf("SELECT storage_id FROM %q WHERE validity=1 AND instr(%Q, storage_path)", MEDIA_SVC_DB_TABLE_STORAGE, path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); - SAFE_FREE(storage_path); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0)))