Remove storage scan request on USB block 70/318270/1 accepted/tizen/unified/20250115.124208 accepted/tizen/unified/x/20250115.142742
authorJosh Merlin <josh.merlin@samsung.com>
Tue, 14 Jan 2025 06:01:19 +0000 (14:01 +0800)
committerJiyong Min <jiyong.min@samsung.com>
Wed, 15 Jan 2025 03:48:45 +0000 (03:48 +0000)
Change-Id: I6614f9eae2452861cb7e2a4423dc510b49d4097e
(cherry picked from commit 9ea74156bc29a83fa5b2ffc74d78474b4e492867)

src/scanner-v2/include/media-scanner-scan-v2.h
src/scanner-v2/media-scanner-device-block-v2.c
src/scanner-v2/media-scanner-scan-v2.c

index e7350613ef76d6572562f1cc490e3618233eb937..3c0456ae2bfba78e778e6246a282ead9bf8f411c 100644 (file)
@@ -46,5 +46,6 @@ void msc_deinit_scanner(void);
 int msc_push_scan_request(ms_scan_type_e scan_type, ms_comm_msg_s *recv_msg);
 void msc_send_power_off_request(void);
 void msc_remove_dir_scan_request(ms_comm_msg_s *recv_msg);
+void msc_remove_storage_scan_request(const char *path);
 
 #endif /*_MEDIA_SCANNER_SCAN_V2_H_*/
index e667d05b9fb9e6ad64ac4841a50af24aa659138d..fe551abcf6ab36dfe6165ca9b12feb21ca0b2ec1 100644 (file)
@@ -62,8 +62,10 @@ void msc_device_block_changed_cb(usb_device_h usb_device, char *action, void *us
                if (!ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &status))
                        MS_DBG_ERR("ms_config_get_int[VCONFKEY_FILEMANAGER_DB_STATUS]");
 
-               if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED))
+               if (!(g_async_queue_length(storage_queue2) == 0 && status == VCONFKEY_FILEMANAGER_DB_UPDATED)) {
+                       msc_remove_storage_scan_request(mount_path);
                        msc_set_blocked_path(mount_path);
+               }
 
                if (g_directory_scan_processing2 != 0) {
                        MS_DBG_WARN("Doing directory scanning. Set cancel path");
index 5d484c24bbeee6bf5ae66758b7b0a976fdeb7366..62dbadb1c03793590e62c67f893ff4b7b230a497 100644 (file)
@@ -1445,3 +1445,31 @@ FINALIZE:
        g_mutex_unlock(&scan_req_mutex2);
        MS_DBG_WARN("scan_req_mutex2 is UNLOCKED");
 }
+
+void msc_remove_storage_scan_request(const char *path)
+{
+       int items_to_find = 0;
+       ms_comm_msg_s *msg = NULL;
+
+       MS_DBG_INFO("Removing path [%s] from storage queue. Acquiring lock.", path);
+       g_async_queue_lock(storage_queue2);
+       MS_DBG_INFO("storage_queue2 LOCKED");
+
+       items_to_find = g_async_queue_length_unlocked(storage_queue2);
+
+       MS_DBG_INFO("storage_queue2 has %d items", items_to_find);
+       while (items_to_find-- > 0) {
+               msg = g_async_queue_pop_unlocked(storage_queue2);
+               if ((msg->msg_type == MS_MSG_STORAGE_PARTIAL || msg->msg_type == MS_MSG_STORAGE_ALL) && (g_strcmp0(msg->msg, path) == 0)) {
+                       MS_DBG_WARN("Removing storage request [%s]", path);
+                       g_free(msg);
+               } else {
+                       g_async_queue_push_unlocked(storage_queue2, msg);
+               }
+       }
+
+       MS_DBG_INFO("Remove storage scan request done");
+
+       g_async_queue_unlock(storage_queue2);
+       MS_DBG_INFO("storage_queue2 UNLOCKED");
+}