summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2020-03-05 16:09:42 +0900
committerMinje ahn <minje.ahn@samsung.com>2020-03-06 01:30:17 +0000
commit2d65ead5500610b8f68927656e60a22d058eb590 (patch)
treed7103a88ffb55abb4569014843c8cc3c7033242f
parenta30c93a33b2b1cc004955a570735548736aa468d (diff)
downloadlibmedia-service-2d65ead5500610b8f68927656e60a22d058eb590.tar.gz
libmedia-service-2d65ead5500610b8f68927656e60a22d058eb590.tar.bz2
libmedia-service-2d65ead5500610b8f68927656e60a22d058eb590.zip
Improve function to get storage id
Change-Id: I2e52a2b5a86f58fe2e921bccbd192754b3915bdd Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rwxr-xr-xsrc/common/media-svc-storage.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c
index 50cc443..bc459af 100755
--- a/src/common/media-svc-storage.c
+++ b/src/common/media-svc-storage.c
@@ -216,9 +216,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");
@@ -234,16 +231,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)))