Close directory first to avoid errors in unmounting 32/318332/1 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20240927.171120 accepted/tizen/unified/x/20240929.082809
authorjosh.merlin <josh.merlin@samsung.com>
Fri, 27 Sep 2024 02:36:54 +0000 (10:36 +0800)
committerjosh.merlin <josh.merlin@samsung.com>
Fri, 27 Sep 2024 02:36:54 +0000 (10:36 +0800)
Change-Id: I788b1436392ec3916fe02eaa30c48932ec5c3332

src/scanner-v2/media-scanner-scan-v2.c

index 51869dc..e07782a 100644 (file)
@@ -188,6 +188,8 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, ch
        bool is_recursive = (msg_type == MS_MSG_DIRECTORY_SCANNING);
        char *new_start_path = NULL;
 
+       bool is_stop_scan = false;
+
        int scan_count = 0;
        int sleep_count = 0;
 
@@ -356,9 +358,7 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, ch
        goto END_SCAN;
 
 STOP_SCAN:
-       MS_DBG_ERR("stop folder scan...");
-       ms_set_folder_scan_status(storage_id, current_path, MS_DIR_SCAN_STOP, uid);
-       MS_SAFE_FREE(current_path);
+       is_stop_scan = true;
 
 END_SCAN:
        if (dir) {
@@ -366,6 +366,12 @@ END_SCAN:
                dir = NULL;
        }
 
+       if(is_stop_scan) {
+               MS_DBG_ERR("stop folder scan...");
+               ms_set_folder_scan_status(storage_id, current_path, MS_DIR_SCAN_STOP, uid);
+               MS_SAFE_FREE(current_path);
+       }
+
        g_free(new_start_path);
        __msc_set_dir_scan_cur_path(NULL);
 
@@ -391,6 +397,8 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
        int (*scan_function)(sqlite3 *, const char*, const char*, uid_t) = NULL;
        char *new_start_path = NULL;
 
+       bool is_stop_scan = false;
+
        int scan_count = 0;
        int sleep_count = 0;
 
@@ -578,9 +586,7 @@ NEXT_SCAN:
        goto END_SCAN;
 
 STOP_SCAN:
-       if (current_path != NULL)
-               ms_set_folder_scan_status(storage_id, current_path, MS_DIR_SCAN_STOP, uid);
-       MS_SAFE_FREE(current_path);
+       is_stop_scan = true;
 
 END_SCAN:
        if (dir) {
@@ -588,6 +594,12 @@ END_SCAN:
                dir = NULL;
        }
 
+       if(is_stop_scan) {
+               if (current_path != NULL)
+                       ms_set_folder_scan_status(storage_id, current_path, MS_DIR_SCAN_STOP, uid);
+               MS_SAFE_FREE(current_path);
+       }
+
        g_free(new_start_path);
        __msc_set_storage_scan_cur_path(NULL);
        g_ptr_array_free(dir_array, TRUE);