#endif
-int media_svc_cleanup_db(sqlite3 *handle, uid_t uid);
int media_svc_get_user_version(sqlite3 *handle, int *user_version);
int media_svc_create_table(uid_t uid);
int media_svc_check_item_exist_by_path(sqlite3 *handle, const char *storage_id, const char *path);
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_do_cleanup(sqlite3 *db_handle, uid_t uid)
-{
- int ret = MS_MEDIA_ERR_NONE;
- sqlite3_stmt *sql_stmt = NULL;
- GList *sql_list = NULL;
- int item_cnt = 0;
- int idx = 0;
- /*Make one query to drop table, delete folder, delete storage.. And only for external USB storage */
- char *sql = sqlite3_mprintf("select 'DROP TABLE ''' || storage_uuid || ''';DELETE FROM folder WHERE storage_uuid = ''' || storage_uuid || ''';DELETE FROM storage WHERE storage_uuid = ''' || storage_uuid || ''';' from storage where validity = 0 AND storage_type=2;");
-
- ret = _media_svc_sql_prepare_to_step_simple(db_handle, sql, &sql_stmt);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("error when get user_version.");
- return ret;
- }
-
- while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
- if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0)))
- sql_list = g_list_append(sql_list, strdup((char *)sqlite3_column_text(sql_stmt, 0)));
- }
-
- SQLITE3_FINALIZE(sql_stmt);
-
- if ((sql_list != NULL) && (g_list_length(sql_list) > 0)) {
- item_cnt = g_list_length(sql_list);
-
- for (idx = 0; idx < item_cnt; idx++) {
- char *query = NULL;
- query = g_list_nth_data(sql_list, idx);
-
- if (STRING_VALID(query)) {
- sql = sqlite3_mprintf("%s", query);
- _media_svc_sql_query(sql, uid);
- SQLITE3_SAFE_FREE(sql);
- SAFE_FREE(query);
- }
- }
- g_list_free(sql_list);
- }
-
- /*Rebuild index*/
- sql = sqlite3_mprintf("VACUUM;");
- _media_svc_sql_query(sql, uid);
- SQLITE3_SAFE_FREE(sql);
-
- return MS_MEDIA_ERR_NONE;
-}
-
int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt)
{
int err = -1;
#include "media-svc-util.h"
#include "media-svc-db-utils.h"
-#define FOLDER_SCAN_DONE 4
-
static __thread GList *g_media_svc_insert_folder_query_list;
int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid)
#define BATCH_REQUEST_MAX 300
-int media_svc_cleanup_db(sqlite3 *handle, uid_t uid)
-{
- media_svc_debug_fenter();
-
- return _media_svc_do_cleanup(handle, uid);
-}
-
int media_svc_get_user_version(sqlite3 *handle, int *user_version)
{
return _media_svc_get_user_version(handle, user_version);
int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid);
int _media_svc_sql_query(const char *sql_str, uid_t uid);
int _media_svc_get_user_version(sqlite3 *db_handle, int *user_version);
-int _media_svc_do_cleanup(sqlite3 *db_handle, uid_t uid);
int _media_svc_sql_prepare_to_step(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt);
int _media_svc_sql_prepare_to_step_simple(sqlite3 *handle, const char *sql_str, sqlite3_stmt **stmt);
int _media_svc_sql_begin_trans(uid_t uid);