Fix storage update error 37/321337/1 accepted/tizen/unified/20250326.054114 accepted/tizen/unified/x/20250326.070141
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 19 Mar 2025 05:23:42 +0000 (14:23 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 19 Mar 2025 05:23:42 +0000 (14:23 +0900)
Fixed error as below:
1. Fixed an issue where existing root paths would not be deleted.
2. Fixed an issue where the root folder name was not updated.

Change-Id: I5df650e74f23d65d133ffa986ac465a5c7cb2c89
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
packaging/libmedia-service.spec
src/media-svc-storage.c

index 501d5a7b40aec275f937f5670bd6c8638c53167d..4b85348e561e3e5952ec8656910f87ebfdf31169 100644 (file)
@@ -1,7 +1,7 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
 Version:    0.7.5
-Release:    0
+Release:    1
 Group:      Multimedia/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 42ea83b841ccb4dbb6a5235fed6e99b2e78fecbe..e42321de352cc6bfce446f85b04d4312ae9d85ab 100644 (file)
@@ -60,6 +60,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
        int ret = MS_MEDIA_ERR_NONE;
        char *q = NULL;
        g_autofree gchar *old_storage_path = NULL;
+       g_autofree gchar *folder_name = NULL;
        int validity = 0;
 
        media_svc_retvm_if(!storage_id, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
@@ -70,7 +71,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
        /* Remove first */
-       q = sqlite3_mprintf("DELETE FROM %q WHERE media_path LIKE '%q/%%';DELETE FROM %q WHERE folder_path LIKE '%q/%%';DELETE FROM %q WHERE storage_path=%Q;", DB_TABLE_MEDIA, path, DB_TABLE_FOLDER, path, DB_TABLE_STORAGE, path);
+       q = sqlite3_mprintf("DELETE FROM %q WHERE media_path LIKE '%q/%%';DELETE FROM %q WHERE folder_path LIKE '%q/%%' OR folder_path=%Q;DELETE FROM %q WHERE storage_path=%Q;", DB_TABLE_MEDIA, path, DB_TABLE_FOLDER, path, path, DB_TABLE_STORAGE, path);
        ret = _media_svc_sql_query_direct(q, uid);
        sqlite3_free(q);
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
@@ -87,6 +88,13 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
        sqlite3_free(q);
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
+       /*the name of root path on folder table*/
+       folder_name = g_path_get_basename(path);
+       q = sqlite3_mprintf("UPDATE %q SET folder_name=%Q WHERE folder_path=%Q", DB_TABLE_FOLDER, folder_name, path);
+       ret = _media_svc_sql_query_direct(q, uid);
+       sqlite3_free(q);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+
        /*Media table update*/
        q = sqlite3_mprintf("UPDATE %q SET media_path=REPLACE(media_path, %Q, %Q), validity=1 WHERE storage_uuid=%Q", DB_TABLE_MEDIA, old_storage_path, path, storage_id);
        ret = _media_svc_sql_query_direct(q, uid);