parent_folder_path = g_path_get_dirname(folder_path);
- if(!STRING_VALID(parent_folder_path)) {
+ if (!STRING_VALID(parent_folder_path)) {
media_svc_error("error : g_path_get_dirname falied");
SAFE_FREE(parent_folder_path);
return MS_MEDIA_ERR_OUT_OF_MEMORY;
char *temp_parent_uuid = NULL;
char *parent_folder_path = NULL;
- sql = sqlite3_mprintf("SELECT folder_uuid, parent_folder_uuid FROM '%s' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_name);
+ sql = sqlite3_mprintf("SELECT folder_uuid, parent_folder_uuid FROM '%s' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_name);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
SQLITE3_FINALIZE(sql_stmt);
/*root path can be null*/
- if(!STRING_VALID(parent_folder_uuid)) {
+ if (!STRING_VALID(parent_folder_uuid)) {
bool is_root = FALSE;
ret = __media_svc_is_root_path(folder_name, &is_root, uid);
return MS_MEDIA_ERR_NONE;
}
- /* Notice : Below code is the code only for inserting parent folder uuid when upgrade the media db version 3 to 4 */
+ /* Notice : Below code is the code only for inserting parent folder uuid when upgrade the media db version 3 to 4 */
/* Check parent folder uuid */
- if(!STRING_VALID(parent_folder_uuid)) {
+ if (!STRING_VALID(parent_folder_uuid)) {
/* update parent_uuid */
media_svc_error("[No-Error] there is no parent folder uuid. PLEASE CHECK IT");
parent_folder_path = g_path_get_dirname(folder_name);
- if(!STRING_VALID(parent_folder_path)) {
+ if (!STRING_VALID(parent_folder_path)) {
media_svc_error("error : g_path_get_dirname falied.");
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- if(STRING_VALID(storage_id))
- sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, parent_folder_path);
+ if (STRING_VALID(storage_id))
+ sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, parent_folder_path);
else
- sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_path);
+ sql = sqlite3_mprintf("SELECT folder_uuid FROM '%s' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_path);
SAFE_FREE(parent_folder_path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret == MS_MEDIA_ERR_NONE) {
- temp_parent_uuid = (char *)sqlite3_column_text(sql_stmt, 0);
+ temp_parent_uuid = (char *)sqlite3_column_text(sql_stmt, 0);
if (temp_parent_uuid != NULL) {
_strncpy_safe(parent_folder_uuid, temp_parent_uuid, MEDIA_SVC_UUID_SIZE+1);
}
SQLITE3_FINALIZE(sql_stmt);
}
- if(STRING_VALID(parent_folder_uuid)) {
- if(STRING_VALID(storage_id))
- sql = sqlite3_mprintf("UPDATE %q SET parent_folder_uuid = '%q' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_uuid, storage_id, folder_name);
+ if (STRING_VALID(parent_folder_uuid)) {
+ if (STRING_VALID(storage_id))
+ sql = sqlite3_mprintf("UPDATE %q SET parent_folder_uuid = '%q' WHERE storage_uuid = '%q' AND path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_uuid, storage_id, folder_name);
else
- sql = sqlite3_mprintf("UPDATE %q SET parent_folder_uuid = '%q' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_uuid, folder_name);
+ sql = sqlite3_mprintf("UPDATE %q SET parent_folder_uuid = '%q' WHERE path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, parent_folder_uuid, folder_name);
ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
} else {
}
static int __media_svc_append_folder(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type,
- const char *folder_id, const char *folder_path, const char *parent_folder_uuid, bool stack_query, uid_t uid)
+ const char *folder_id, const char *folder_path, const char *parent_folder_uuid, bool stack_query, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *folder_name = NULL;
char *sql = sqlite3_mprintf("INSERT INTO %s (folder_uuid, path, name, storage_uuid, storage_type, modified_time, name_pinyin, parent_folder_uuid) \
values (%Q, %Q, %Q, %Q, '%d', '%d', %Q, %Q); ",
- MEDIA_SVC_DB_TABLE_FOLDER, folder_id, folder_path, folder_name, storage_id, storage_type, folder_modified_date, folder_name_pinyin, parent_folder_uuid);
+ MEDIA_SVC_DB_TABLE_FOLDER, folder_id, folder_path, folder_name, storage_id, storage_type, folder_modified_date, folder_name_pinyin, parent_folder_uuid);
- if(!stack_query)
+ if (!stack_query)
{
ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
SAFE_FREE(dir_path);
}
- if(STRING_VALID(folder_uuid)) {
+ if (STRING_VALID(folder_uuid)) {
_strncpy_safe(folder_id, folder_uuid, MEDIA_SVC_UUID_SIZE + 1);
} else {
media_svc_error("Fail to get folder_uuid");
dir_path = g_path_get_dirname(path);
- ret = _media_svc_get_and_append_folder(handle, storage_id, dir_path, storage_type, folder_id, uid);
+ ret = _media_svc_get_and_append_folder(handle, storage_id, dir_path, storage_type, folder_id, uid);
SAFE_FREE(dir_path);
char *sql = NULL;
sql = sqlite3_mprintf("DELETE FROM '%s' WHERE folder_uuid IN (SELECT folder_uuid FROM '%s' WHERE folder_uuid NOT IN (SELECT folder_uuid FROM '%s'))",
- MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_FOLDER, storage_id);
+ MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TABLE_FOLDER, storage_id);
ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
char **folder_uuid = NULL;
int i = 0;
- ret = __media_svc_count_all_folders(handle, start_path, &cnt);
+ ret = __media_svc_count_all_folders(handle, start_path, &cnt);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("error when __media_svc_count_all_folders. err = [%d]", ret);
return ret;
}
/* free all data */
- for (i = 0; i < idx; i++) {
+ for (i = 0; i < idx; i++) {
SAFE_FREE(folder_uuid[i]);
}
SAFE_FREE(folder_uuid);
ERROR:
/* free all data */
- for (i = 0; i < idx; i++) {
+ for (i = 0; i < idx; i++) {
SAFE_FREE((*folder_list)[i]);
SAFE_FREE(folder_uuid[i]);
}
} else {
sql = sqlite3_mprintf("UPDATE '%s' SET validity=1 WHERE storage_uuid = '%q' AND path = '%q'", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, path);
- if(!stack_query)
+ if (!stack_query)
{
ret = _media_svc_sql_query(handle, sql, uid);
sqlite3_free(sql);
return ret;
}
-int _media_svc_count_folder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count)
+int _media_svc_count_folder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_count_subfolder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count)
+int _media_svc_count_subfolder_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
SQLITE3_FINALIZE(sql_stmt);
- if(!STRING_VALID(folder_id))
+ if (!STRING_VALID(folder_id))
{
media_svc_error("Not found valid storage id [%s]", path);
ret = MS_MEDIA_ERR_INVALID_PARAMETER;