From: Minje Ahn Date: Thu, 11 Apr 2019 03:53:44 +0000 (+0900) Subject: Match columns of storage with filter keyword X-Git-Tag: accepted/tizen/unified/20190412.124707^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7679e9a68dc33081c3f522394a3083442b1e1064;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Match columns of storage with filter keyword Change-Id: I84cfbff3c6ab388d0028fb66281a1d5d151c6afd Signed-off-by: Minje Ahn --- diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index 9ac3e62..9bb3f8a 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -721,7 +721,7 @@ int _media_svc_init_table_query(const char *event_table_name) media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); /*storage*/ - ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_STORAGE], "storage_uuid", MEDIA_SVC_DB_TYPE_TEXT, "PRIMARY KEY", USER_V3, NULL, false, false, false); + ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_STORAGE], "storage_id", MEDIA_SVC_DB_TYPE_TEXT, "PRIMARY KEY", USER_V3, NULL, false, false, false); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); ret = __media_svc_add_column_info(&column_list[MEDIA_SVC_DB_LIST_STORAGE], "storage_path", MEDIA_SVC_DB_TYPE_TEXT, "NOT NULL", USER_V3, NULL, false, false, false); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -1577,7 +1577,7 @@ int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid) snprintf(view_query, sizeof(view_query), "DROP VIEW IF EXISTS %s; CREATE VIEW IF NOT EXISTS %s AS SELECT * from %s ", MEDIA_SVC_DB_VIEW_MEDIA, MEDIA_SVC_DB_VIEW_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA); /*Select list of storage*/ - sql = sqlite3_mprintf("SELECT storage_uuid FROM '%s' WHERE validity=1 AND storage_uuid != '%s'", MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_MEDIA); + sql = sqlite3_mprintf("SELECT storage_id FROM '%s' WHERE validity=1", MEDIA_SVC_DB_TABLE_STORAGE); ret = _media_svc_sql_prepare_to_step_simple(db_handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index 7ab1b07..0ec55c9 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -39,7 +39,7 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **sto *storage_path = NULL; *validity = 0; - sql = sqlite3_mprintf("SELECT storage_path, validity FROM '%q' WHERE storage_uuid=%Q", MEDIA_SVC_DB_TABLE_STORAGE, storage_id); + sql = sqlite3_mprintf("SELECT storage_path, validity FROM '%q' WHERE storage_id=%Q", MEDIA_SVC_DB_TABLE_STORAGE, storage_id); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -76,7 +76,7 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **sto int _media_svc_append_storage(const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; - char *sql = sqlite3_mprintf("INSERT INTO %q (storage_uuid, storage_path, storage_type) values (%Q, %Q, %d);", + char *sql = sqlite3_mprintf("INSERT INTO %q (storage_id, storage_path, storage_type) values (%Q, %Q, %d);", MEDIA_SVC_DB_TABLE_STORAGE, storage_id, storage_path, storage_type); ret = _media_svc_sql_query(sql, uid); @@ -100,7 +100,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); /*Storage table update*/ - sql = sqlite3_mprintf("UPDATE '%q' SET storage_path=%Q WHERE storage_uuid=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, path, storage_id); + sql = sqlite3_mprintf("UPDATE '%q' SET storage_path=%Q WHERE storage_id=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, path, storage_id); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); if (ret != MS_MEDIA_ERR_NONE) { @@ -145,7 +145,7 @@ int __media_svc_delete_thumbnail(sqlite3 *handle, const char *storage_id) return ret; } -int _media_svc_delete_invalid_storage(sqlite3 *handle, ms_user_storage_type_e storage_type, uid_t uid) +int _media_svc_delete_invalid_storage(sqlite3 *handle, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; char *sql = NULL; @@ -154,8 +154,7 @@ int _media_svc_delete_invalid_storage(sqlite3 *handle, ms_user_storage_type_e st sqlite3_stmt *sql_stmt = NULL; GArray *storage_list = NULL; - /* Get invalid storage_uuid (with storage_type)*/ - sql = sqlite3_mprintf("SELECT storage_uuid FROM '%q' WHERE validity = 0 AND storage_type=%d;", MEDIA_SVC_DB_TABLE_STORAGE, storage_type); + sql = sqlite3_mprintf("SELECT storage_id FROM '%q' WHERE validity=0;", MEDIA_SVC_DB_TABLE_STORAGE); ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt); media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret); @@ -194,8 +193,7 @@ int _media_svc_delete_invalid_storage(sqlite3 *handle, ms_user_storage_type_e st } /* Update storage, folder table */ - sql = sqlite3_mprintf("DELETE FROM '%q' WHERE validity=0 AND storage_type=%d;DELETE FROM '%q' WHERE validity=0 AND storage_type=%d;", - MEDIA_SVC_DB_TABLE_STORAGE, storage_type, MEDIA_SVC_DB_TABLE_FOLDER, storage_type); + sql = sqlite3_mprintf("DELETE FROM %q WHERE validity=0;DELETE FROM %q WHERE validity=0;", MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_FOLDER); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -226,9 +224,9 @@ int _media_svc_update_storage_validity(const char *storage_id, int validity, uid char *sql = NULL; if (storage_id == NULL) - sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE storage_uuid!='media';", MEDIA_SVC_DB_TABLE_STORAGE, validity); + sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d;", MEDIA_SVC_DB_TABLE_STORAGE, validity); else - sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE storage_uuid=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, validity, storage_id); + sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE storage_id=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, validity, storage_id); ret = _media_svc_sql_query(sql, uid); SQLITE3_SAFE_FREE(sql); @@ -265,7 +263,7 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage storage_path = strndup(path, strlen(path) - remain_len); - sql = sqlite3_mprintf("SELECT storage_uuid 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 storage_path = '%q'", MEDIA_SVC_DB_TABLE_STORAGE, storage_path); ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt); SAFE_FREE(storage_path); diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 19b934f..abc7af9 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -880,7 +880,7 @@ int media_svc_insert_storage(sqlite3 *handle, const char *storage_id, const char media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret); /* Remove external storage that validity is 0 */ - ret = _media_svc_delete_invalid_storage(handle, storage_type, uid); + ret = _media_svc_delete_invalid_storage(handle, uid); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Delete invalid storage failed : %d", ret); return ret; diff --git a/src/include/common/media-svc-storage.h b/src/include/common/media-svc-storage.h index 6da41e2..f8b727d 100755 --- a/src/include/common/media-svc-storage.h +++ b/src/include/common/media-svc-storage.h @@ -27,7 +27,7 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid); int _media_svc_append_storage(const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid); int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid); -int _media_svc_delete_invalid_storage(sqlite3 *handle, ms_user_storage_type_e storage_type, uid_t uid); +int _media_svc_delete_invalid_storage(sqlite3 *handle, uid_t uid); int _media_svc_update_storage_validity(const char *storage_id, int validity, uid_t uid); int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage_id, uid_t uid);