'VCONFKEY_FILEMANAGER_DB_STATUS' is no longer used in scanner-v1.
So, move related code to scanner-v2.
Change-Id: I47136d68c4e1accb1d494d0c635fa3508c401047
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
#include "media-util.h"
#include "media-common-types.h"
-bool ms_config_get_int(const char *key, int *value);
-bool ms_config_set_int(const char *key, int value);
-
bool ms_is_valid_symlink(const char *path);
-int ms_check_file_path(const char *file_path, uid_t uid);
-int ms_check_ignore_dir(const char *full_path, uid_t uid);
-int ms_check_scan_ignore(char * path, uid_t uid);
-int ms_set_db_status(ms_db_status_type_t status);
+int ms_verify_all_parent_dirs(const char *full_path, uid_t uid);
+int ms_check_scan_ignore(char *path, uid_t uid);
int ms_set_power_mode(ms_db_status_type_t status);
void ms_trim_dir_path(char *dir_path);
#ifdef _USE_TVPD_MODE
+
+bool ms_config_get_int(const char *key, int *value);
+bool ms_config_set_int(const char *key, int value);
+int ms_set_db_status(ms_db_status_type_t status);
int ms_get_remain_space(uint64_t *free_space);
int ms_check_size_mediadb(uid_t uid, uint64_t *db_size);
-bool ms_storage_mount_status(const char* start_path);
+bool ms_storage_mount_status(const char *start_path);
bool ms_is_support_pvr(void);
int ms_set_vip_process(void);
#endif
typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, int, uid_t);
typedef int (*SET_FOLDER_VALIDITY)(sqlite3 *, const char *, const char *, int, bool, uid_t);
-typedef int (*CHECK_DB)(sqlite3*, uid_t);
+typedef int (*CHECK_DB)(sqlite3 *, uid_t);
typedef int (*CHECK_STORAGE)(sqlite3 *, const char *, char **, int *, uid_t);
typedef int (*INSERT_STORAGE)(sqlite3 *, const char *, int, const char *, uid_t);
typedef int (*UPDATE_STORAGE)(sqlite3 *, const char *, const char *, uid_t);
typedef int (*SET_STORAGE_VALIDITY)(sqlite3 *, const char *, int, uid_t uid);
typedef int (*SET_ALL_STORAGE_VALIDITY)(sqlite3 *, int, uid_t);
-typedef int (*CHECK_FOLDER_EXIST)(sqlite3*, const char*, const char*);
+typedef int (*CHECK_FOLDER_EXIST)(sqlite3 *, const char *, const char *);
typedef int (*GET_MEDIA_TYPE)(const char *, int *);
typedef int (*REFRESH_ITEM)(sqlite3 *, const char *, const char *, uid_t);
#ifdef _USE_TVPD_MODE
-typedef int (*CLEANUP_DB)(sqlite3*, uid_t);
+typedef int (*CLEANUP_DB)(sqlite3 *, uid_t);
typedef int (*UPDATE_FOLDER_TIME)(sqlite3 *, const char *, const char *, uid_t);
typedef int (*GET_UUID)(char **);
typedef int (*SET_STORAGE_SCAN_STATUS)(sqlite3 *, const char *, int, uid_t);
typedef int (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, int, uid_t);
-typedef int (*GET_EXTRACT_LIST)(sqlite3*, const char*, int, const char*, int, void*);
-typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3*, const char*, int, void *);
+typedef int (*GET_EXTRACT_LIST)(sqlite3 *, const char*, int, const char *, int, void*);
+typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3 *, const char *, int, void *);
typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(sqlite3 *, const char *, const char *, bool, uid_t);
typedef int (*DELETE_INVALID_FOLDER_BY_PATH)(sqlite3 *, const char *, const char *, uid_t);
typedef int (*GET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int *);
#include <sys/types.h>
#include <fcntl.h>
-#include <vconf.h>
#include <sys/statvfs.h>
#include <sys/stat.h>
#ifdef _USE_TVPD_MODE
+#include <vconf.h>
#include <sys/prctl.h>
#include <usb-device.h>
#endif
#include "media-common-system.h"
#include "media-common-utils.h"
+#ifdef _USE_TVPD_MODE
bool ms_config_get_int(const char *key, int *value)
{
int err;
return false;
}
-#ifdef _USE_TVPD_MODE
int ms_get_remain_space(uint64_t *free_space)
{
int ret = MS_MEDIA_ERR_NONE;
#endif
}
-int ms_check_file_path(const char *file_path, uid_t uid)
-{
- ms_user_storage_type_e storage_type = -1;
- int ret = MS_MEDIA_ERR_NONE;
-
- if (!MS_STRING_VALID(file_path)) {
- MS_DBG_ERR("Invalid path");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- ret = ms_user_get_storage_type(uid, file_path, &storage_type);
- MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
-
- if (!g_file_test(file_path, G_FILE_TEST_IS_REGULAR)) {
- MS_DBG_SERR("g_file_test fail [%s]", file_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int ms_check_ignore_dir(const char *full_path, uid_t uid)
+int ms_verify_all_parent_dirs(const char *full_path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *dir_path = NULL;
char *next = NULL;
int next_pos = 0;
+ ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
- ret = ms_check_file_path(full_path, uid);
- MS_DBG_RETV_IF(ret != MS_MEDIA_ERR_NONE, ret);
+ ret = ms_user_get_storage_type(uid, full_path, &storage_type);
+ MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Invalid path");
- if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && !strncmp(full_path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB))) {
- next_pos = strlen(MEDIA_ROOT_PATH_USB) + 1;
- } else {
+ if (storage_type == MS_USER_STORAGE_INTERNAL) {
ret = ms_user_get_internal_root_path(uid, &dir_path);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_internal_root_path() fail");
next_pos = strlen(dir_path);
g_free(dir_path);
dir_path = NULL;
+ } else {
+ next_pos = strlen(MEDIA_ROOT_PATH_USB) + 1;
}
while ((next = strstr(full_path + next_pos, "/"))) {
return ret;
}
-int ms_check_scan_ignore(char * path, uid_t uid)
+int ms_check_scan_ignore(char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
const char *ignore_file = ".scan_ignore";
return ret;
}
-#endif
int ms_set_db_status(ms_db_status_type_t status)
{
MS_DBG_ERR("ms_config_set_int failed");
return MS_MEDIA_ERR_INTERNAL;
}
+#endif
int ms_set_power_mode(ms_db_status_type_t status)
{
ms_register_start(true, pid);
for (i = 0; path_list[i][0] != '\0'; i++) {
- ret = ms_check_ignore_dir(path_list[i], uid);
+ ret = ms_verify_all_parent_dirs(path_list[i], uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_SERR("Invalid path : %s", path_list[i]);
continue;
ret = ms_connect_db(&handle, scan_data->uid);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_connect_db failed");
- ms_set_db_status(MS_DB_UPDATING);
+ ms_set_power_mode(MS_DB_UPDATING);
ret = ms_validity_change_all_items(handle, scan_data->storage_id, false, scan_data->uid);
if (ret != MS_MEDIA_ERR_NONE) {
ret = ms_connect_db(&handle, scan_data->uid);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_connect_db failed");
- ms_set_db_status(MS_DB_UPDATING);
+ ms_set_power_mode(MS_DB_UPDATING);
ms_register_start(false, 0);
ret = __msc_db_update(handle, scan_data->storage_id, scan_data);
/* send notification */
ms_send_dir_update_noti(scan_data->msg, NULL, MS_ITEM_UPDATE, scan_data->pid);
- if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP)
- ms_set_db_status(MS_DB_STOPPED);
- else
- ms_set_db_status(MS_DB_UPDATED);
+ if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP)
+ ms_set_power_mode(MS_DB_UPDATED);
NEXT:
if (__msc_is_power_off())
goto _POWEROFF;
ms_register_start(true, pid);
for (i = 0; path_list[i][0] != '\0'; i++) {
- ret = ms_check_ignore_dir(path_list[i], uid);
+ ret = ms_verify_all_parent_dirs(path_list[i], uid);
if (ret != MS_MEDIA_ERR_NONE) {
MS_DBG_SERR("Invalid path : %s", path_list[i]);
continue;
#include <sys/wait.h>
#include <sys/types.h>
#include <malloc.h>
-#include <vconf.h>
#include <iniparser.h>
#include <cpu-boosting.h>
#include "media-server-db-manage.h"
#ifdef _USE_TVPD_MODE
+#include <vconf.h>
+
#define MS_VCONF_KEY_RESET_STATUS "db/media_server/reset_status"
#define SMARTHUB_RESET_VCONF "db/smarthub/reset/firstscreen"
*/
#include <glib.h>
-#include <vconf.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "media-server-scanner.h"
#include <tzplatform_config.h>
-
+#ifdef _USE_TVPD_MODE
+#include <vconf.h>
#define VCONFKEY_PRIVATE_EXTRACTSTATUS "db/private/extractstatus"
+#endif
#define MEDIA_SERVER_PATH tzplatform_mkpath(TZ_SYS_BIN, "media-scanner")
#define MEDIA_SERVER_PATH_V2 tzplatform_mkpath(TZ_SYS_BIN, "media-scanner-v2")
{
return (owner_list) ? owner_list->len : 0;
}
-
+#ifdef _USE_TVPD_MODE
static ms_db_status_type_t __ms_check_scanning_status(void)
{
int status;
if (status == VCONFKEY_FILEMANAGER_DB_UPDATING)
return MS_DB_UPDATING;
}
-#ifdef _USE_TVPD_MODE
+
if (ms_config_get_int(VCONFKEY_PRIVATE_EXTRACTSTATUS, &status)) {
MS_DBG("extract status %d", status);
if (status == MS_DB_UPDATING)
return MS_DB_UPDATING;
}
-#endif
return MS_DB_UPDATED;
}
+#endif
static gboolean __ms_stop_scanner(gpointer user_data)
{
g_mutex_unlock(&scanner_mutex);
return G_SOURCE_CONTINUE;
}
-
+#ifdef _USE_TVPD_MODE
if (__ms_check_scanning_status() == MS_DB_UPDATING) {
MS_DBG("DB is updating");
g_mutex_unlock(&scanner_mutex);
return G_SOURCE_CONTINUE;
}
-
+#endif
if (ms_req_num > 0) {
MS_DBG("[%d] request(s) remain(s)", ms_req_num);
g_mutex_unlock(&scanner_mutex);