summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminje.ahn <minje.ahn@samsung.com>2024-03-11 17:18:21 +0900
committerMinje ahn <minje.ahn@samsung.com>2024-03-11 23:08:04 +0000
commit4bcba9e34c99b70933472444fdcb98fec2587394 (patch)
tree9329d42764328c9ca2ee186aa5ac8dfc91cfbb61
parenta2704ea41ef57d03e83fca75563ce9ecb3079398 (diff)
downloadlibmedia-service-4bcba9e34c99b70933472444fdcb98fec2587394.tar.gz
libmedia-service-4bcba9e34c99b70933472444fdcb98fec2587394.tar.bz2
libmedia-service-4bcba9e34c99b70933472444fdcb98fec2587394.zip
Use sql function instead
SQLITE supports 'unixepoch()' function since 3.38.0 So we update media table schema to 'added_time integer DEFAULT (unixepoch())'. Change-Id: I78eb2ef87896f346b11c1c4507e3058bb019e504 Signed-off-by: minje.ahn <minje.ahn@samsung.com>
-rwxr-xr-xsrc/common/media-svc-db-utils.c2
-rwxr-xr-xsrc/common/media-svc-media.c10
-rw-r--r--src/common/media-svc-util.c3
-rwxr-xr-xsrc/include/common/media-svc-util.h2
4 files changed, 5 insertions, 12 deletions
diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c
index bea6cae..954cc4f 100755
--- a/src/common/media-svc-db-utils.c
+++ b/src/common/media-svc-db-utils.c
@@ -362,7 +362,7 @@ int _media_svc_init_table_query(void)
__add_column_info(&column_list[DB_LIST_MEDIA], "media_type", DB_TYPE_INT, NULL, false, false, true);
__add_column_info(&column_list[DB_LIST_MEDIA], "media_mime_type", DB_TYPE_TEXT, NULL, false, false, true);
__add_column_info(&column_list[DB_LIST_MEDIA], "media_size", DB_TYPE_INT, "DEFAULT 0", false, false, true);
- __add_column_info(&column_list[DB_LIST_MEDIA], "media_added_time", DB_TYPE_INT, "DEFAULT 0", false, false, true);
+ __add_column_info(&column_list[DB_LIST_MEDIA], "media_added_time", DB_TYPE_INT, "DEFAULT (unixepoch())", false, false, true);
__add_column_info(&column_list[DB_LIST_MEDIA], "media_modified_time", DB_TYPE_INT, "DEFAULT 0", false, false, true);
__add_column_info(&column_list[DB_LIST_MEDIA], "folder_id", DB_TYPE_INT, "DEFAULT 0", false, false, false);
__add_column_info(&column_list[DB_LIST_MEDIA], "media_thumbnail_path", DB_TYPE_TEXT, NULL, false, false, true);
diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c
index 57afd2b..e88b931 100755
--- a/src/common/media-svc-media.c
+++ b/src/common/media-svc-media.c
@@ -71,11 +71,11 @@ int _media_svc_insert_item_with_data(bool is_direct, media_svc_content_info_s *c
{
int ret = MS_MEDIA_ERR_NONE;
- const char *db_fields = "media_id, media_path, media_display_name, media_type, media_mime_type, media_size, media_added_time, media_modified_time, folder_id, media_thumbnail_path, media_title, album_id, media_album, media_artist, media_album_artist, media_genre, media_year, media_recorded_date, media_copyright, media_track_num, media_width, media_height, media_datetaken, media_orientation, storage_uuid";
+ const char *db_fields = "media_id, media_path, media_display_name, media_type, media_mime_type, media_size, media_modified_time, folder_id, media_thumbnail_path, media_title, album_id, media_album, media_artist, media_album_artist, media_genre, media_year, media_recorded_date, media_copyright, media_track_num, media_width, media_height, media_datetaken, media_orientation, storage_uuid";
- const char *db_fields_basic = "media_id, media_path, media_display_name, media_type, media_mime_type, media_size, media_added_time, media_modified_time, folder_id, album_id, storage_uuid";
+ const char *db_fields_basic = "media_id, media_path, media_display_name, media_type, media_mime_type, media_size, media_modified_time, folder_id, album_id, storage_uuid";
- char *sql = sqlite3_mprintf("INSERT INTO %q(%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %lld, %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, %d, %Q, %d, %Q);",
+ char *sql = sqlite3_mprintf("INSERT INTO %q(%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %lld, %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, %d, %Q, %d, %Q);",
DB_TABLE_MEDIA, db_fields,
content_info->media_uuid,
content_info->path,
@@ -83,7 +83,6 @@ int _media_svc_insert_item_with_data(bool is_direct, media_svc_content_info_s *c
content_info->media_type,
content_info->mime_type,
content_info->size,
- content_info->added_time,
content_info->modified_time,
content_info->folder_id,
content_info->thumbnail_path,
@@ -108,7 +107,7 @@ int _media_svc_insert_item_with_data(bool is_direct, media_svc_content_info_s *c
media_svc_debug("Query length is over %d byte.. So, remake query using only basic information..", MEDIA_SVC_QUERY_LEN_MAX - 1);
SQLITE3_SAFE_FREE(sql);
- sql = sqlite3_mprintf("INSERT INTO %q(%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %lld, %d, %Q);",
+ sql = sqlite3_mprintf("INSERT INTO %q(%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %lld, %d, %Q);",
DB_TABLE_MEDIA, db_fields_basic,
content_info->media_uuid,
content_info->path,
@@ -116,7 +115,6 @@ int _media_svc_insert_item_with_data(bool is_direct, media_svc_content_info_s *c
content_info->media_type,
content_info->mime_type,
content_info->size,
- content_info->added_time,
content_info->modified_time,
content_info->folder_id,
content_info->album_id,
diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c
index 1db380d..486f21e 100644
--- a/src/common/media-svc-util.c
+++ b/src/common/media-svc-util.c
@@ -385,7 +385,6 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
memset(&st, 0, sizeof(struct stat));
if (stat(path, &st) == 0) {
content_info->modified_time = st.st_mtime;
- content_info->timeline = content_info->modified_time;
content_info->size = st.st_size;
} else {
media_svc_stderror("stat failed");
@@ -400,8 +399,6 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
content_info->storage_uuid = g_strdup(storage_id);
media_svc_retv_del_if(content_info->storage_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- time(&content_info->added_time);
-
content_info->media_uuid = __media_info_generate_uuid();
media_svc_retv_del_if(content_info->media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h
index d38de2d..4849395 100755
--- a/src/include/common/media-svc-util.h
+++ b/src/include/common/media-svc-util.h
@@ -65,9 +65,7 @@ typedef struct {
int media_type; /**< Type of media file : internal/external */
char *mime_type; /**< Full path and file name of media file */
unsigned long long size; /**< size */
- time_t added_time; /**< added time, time_t */
time_t modified_time; /**< modified time, time_t */
- time_t timeline; /**< timeline of media, time_t */
long long int folder_id; /**< Unique ID of folder */
int album_id; /**< Unique ID of album */
char *thumbnail_path; /**< Thumbnail image file path */