Fix storage update error 84/321384/1 accepted/tizen_9.0_unified tizen_9.0 accepted/tizen/9.0/unified/20250327.154356 accepted/tizen/9.0/unified/20250327.160033
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 20 Mar 2025 02:01:26 +0000 (11:01 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 20 Mar 2025 02:01:26 +0000 (11:01 +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: If1f6eed4c49b42a549fc2f61f08293c7192fbb70
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
packaging/libmedia-service.spec
src/media-svc-storage.c

index 757988f1bd80b4ed8ce0e9c03e3237b811d4904c..5333e42bdec13402f54601197b7502dadb4ed147 100644 (file)
@@ -1,7 +1,7 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
 Version:    0.6.11
-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);