summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2019-11-05 10:08:46 +0900
committerMinje Ahn <minje.ahn@samsung.com>2019-11-05 10:08:46 +0900
commitd661eba24fd3abfd19822a29e7ce83a1a7ca707e (patch)
treee381e6775c3d74d5cc39c4aa1663e25ced6be8eb /src
parent1dbcc2241014a5090093bbccce4878010763d2ea (diff)
downloadlibmedia-thumbnail-d661eba24fd3abfd19822a29e7ce83a1a7ca707e.tar.gz
libmedia-thumbnail-d661eba24fd3abfd19822a29e7ce83a1a7ca707e.tar.bz2
libmedia-thumbnail-d661eba24fd3abfd19822a29e7ce83a1a7ca707e.zip
Change-Id: I73bd1cc38f136895d52cd918e4c991fa09d43f76 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/include/util/media-thumb-db.h6
-rwxr-xr-xsrc/media-thumb-internal.c7
-rwxr-xr-xsrc/util/media-thumb-db.c62
3 files changed, 3 insertions, 72 deletions
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
index 0173034..27c21ed 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -29,13 +29,11 @@
#define SQLITE3_FINALIZE(x) {if (x != NULL) sqlite3_finalize(x); }
#define SQLITE3_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } }
-#define SELECT_THUMB_BY_PATH "SELECT media_thumbnail_path FROM media_view WHERE media_path='%q' AND media_thumbnail_path IS NOT NULL;"
-#define SELECT_STORAGE_ID_BY_PATH "SELECT storage_uuid FROM media_view WHERE media_path='%q';"
-#define UPDATE_THUMB_BY_PATH "UPDATE '%q' SET media_thumbnail_path = '%q' WHERE media_path='%q';"
+#define SELECT_THUMB_BY_PATH "SELECT media_thumbnail_path FROM media WHERE media_path='%q' AND media_thumbnail_path IS NOT NULL;"
+#define UPDATE_THUMB_BY_PATH "UPDATE media SET media_thumbnail_path = '%q' WHERE media_path='%q';"
int _media_thumb_get_thumb_from_db(const char *origin_path, char *thumb_path, int max_length, uid_t uid);
int _media_thumb_update_db(const char *origin_path, char *thumb_path, uid_t uid);
-int _media_thumb_get_storage_id_from_db(const char *origin_path, char **storage_id, uid_t uid);
#endif /*_MEDIA_THUMB_DB_H_*/
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index f7225a3..fe2091d 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -374,7 +374,6 @@ int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path
char *hash_name = NULL;
char file_ext[255] = { 0 };
char *get_path = NULL;
- char *storage_id = NULL;
int ret_len = 0;
ms_user_storage_type_e storage_type = -1;
int ret = MS_MEDIA_ERR_NONE;
@@ -397,14 +396,8 @@ int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path
thumb_err("_media_thumb_generate_hash_name fail");
return MS_MEDIA_ERR_INTERNAL;
}
- ret = _media_thumb_get_storage_id_from_db(file_full_path, &storage_id, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_get_storage_id_from_db fail");
- return MS_MEDIA_ERR_INTERNAL;
- }
ret = ms_user_get_root_thumb_store_path(uid, &get_path);
- SAFE_FREE(storage_id);
if (get_path != NULL)
ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index ae76d43..972fdc2 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -75,78 +75,18 @@ int _media_thumb_get_thumb_from_db(const char *origin_path, char *thumb_path, in
return MS_MEDIA_ERR_NONE;
}
-int __media_thumb_get_storage_id(const char *origin_path, uid_t uid, char **storage_id)
-{
- int err = MS_MEDIA_ERR_NONE;
- char *query_string = NULL;
- sqlite3_stmt *stmt = NULL;
- sqlite3 *db_handle = NULL;
-
- thumb_retvm_if(!STRING_VALID(origin_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid origin_path");
-
- query_string = sqlite3_mprintf(SELECT_STORAGE_ID_BY_PATH, origin_path);
- thumb_retvm_if(!STRING_VALID(query_string), MS_MEDIA_ERR_OUT_OF_MEMORY, "Memory allocation is failed");
- thumb_dbg_slog("Query: %s", query_string);
-
- err = media_db_connect(&db_handle, uid, FALSE);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("media_db_connect failed: %d", err);
- db_handle = NULL;
- SQLITE3_SAFE_FREE(query_string);
- return err;
- }
-
- err = sqlite3_prepare_v2(db_handle, query_string, strlen(query_string), &stmt, NULL);
- SQLITE3_SAFE_FREE(query_string);
- if (SQLITE_OK != err) {
- thumb_err("prepare error [%s]", sqlite3_errmsg(db_handle));
- media_db_disconnect(db_handle);
-
- return MS_MEDIA_ERR_DB_INTERNAL;
- }
-
- if (sqlite3_step(stmt) == SQLITE_ROW) {
- *storage_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
- } else {
- thumb_err("end of row [%s]", sqlite3_errmsg(db_handle));
- SQLITE3_FINALIZE(stmt);
- media_db_disconnect(db_handle);
-
- return MS_MEDIA_ERR_DB_INTERNAL;
- }
-
- SQLITE3_FINALIZE(stmt);
- media_db_disconnect(db_handle);
-
- return MS_MEDIA_ERR_NONE;
-}
-
int _media_thumb_update_db(const char *origin_path, char *thumb_path, uid_t uid)
{
int err = MS_MEDIA_ERR_NONE;
char *query_string = NULL;
- char *storage_id = NULL;
thumb_retvm_if(!STRING_VALID(origin_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid origin_path");
- /*Get storage_id */
- err = __media_thumb_get_storage_id(origin_path, uid, &storage_id);
- thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Failed to get storage_id");
- thumb_retvm_if(storage_id == NULL, MS_MEDIA_ERR_OUT_OF_MEMORY, "Memory allocation is failed");
-
- query_string = sqlite3_mprintf(UPDATE_THUMB_BY_PATH, storage_id, thumb_path, origin_path);
- SAFE_FREE(storage_id);
+ query_string = sqlite3_mprintf(UPDATE_THUMB_BY_PATH, thumb_path, origin_path);
thumb_retvm_if(!STRING_VALID(query_string), MS_MEDIA_ERR_OUT_OF_MEMORY, "Memory allocation is failed");
err = media_db_request_update_db(query_string, uid);
SQLITE3_SAFE_FREE(query_string);
return err;
-}
-
-int _media_thumb_get_storage_id_from_db(const char *origin_path, char **storage_id, uid_t uid)
-{
- thumb_retvm_if(!STRING_VALID(origin_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid origin_path");
-
- return __media_thumb_get_storage_id(origin_path, uid, storage_id);
} \ No newline at end of file