@@ -33,12 +33,12 @@ pub fn migrate() -> Result<(), CliError> {
3333 }
3434 Ok ( ( ) )
3535}
36- // Check if the new folders already exists - local-data and fleet-data
36+ // Check if the new folders already exists - local-data or fleet-data
3737fn check_new_folders ( local_new_path : & Path , remote_new_path : & Path ) -> bool {
3838 let local_exists = local_new_path. exists ( ) && local_new_path. is_dir ( ) ;
3939 let fleet_exists = remote_new_path. exists ( ) && remote_new_path. is_dir ( ) ;
4040
41- local_exists && fleet_exists
41+ local_exists || fleet_exists
4242}
4343// Copy the old files in the new paths but leaving the old ones in place
4444fn move_and_rename ( local_base : & Path , remote_base : & Path ) -> Result < ( ) , CliError > {
@@ -156,7 +156,7 @@ fn add_infra_agent_files(
156156) {
157157 // --- LOCAL ---
158158 let old_local_infra_dir = local_base. join ( OLD_SUB_AGENT_DATA_DIR ) . join ( INFRA_AGENT_ID ) ;
159- if old_local_infra_dir. exists ( ) && old_local_infra_dir . is_dir ( ) {
159+ if old_local_infra_dir. exists ( ) {
160160 debug ! (
161161 "Found old local nr-infra directory, adding to migration: {}" ,
162162 old_local_infra_dir. display( )
@@ -177,7 +177,7 @@ fn add_infra_agent_files(
177177 let old_remote_infra_dir = remote_base
178178 . join ( OLD_SUB_AGENT_DATA_DIR )
179179 . join ( INFRA_AGENT_ID ) ;
180- if old_remote_infra_dir. exists ( ) && old_remote_infra_dir . is_dir ( ) {
180+ if old_remote_infra_dir. exists ( ) {
181181 debug ! (
182182 "Found old remote nr-infra directory, adding to migration: {}" ,
183183 old_remote_infra_dir. display( )
@@ -210,7 +210,7 @@ fn add_otel_agent_files(
210210) {
211211 // --- LOCAL ---
212212 let old_local_otel_dir = local_base. join ( OLD_SUB_AGENT_DATA_DIR ) . join ( OTEL_AGENT_ID ) ;
213- if old_local_otel_dir. exists ( ) && old_local_otel_dir . is_dir ( ) {
213+ if old_local_otel_dir. exists ( ) {
214214 debug ! (
215215 "Found old local nrdot directory, adding to migration: {}" ,
216216 old_local_otel_dir. display( )
@@ -229,7 +229,7 @@ fn add_otel_agent_files(
229229
230230 // --- REMOTE ---
231231 let old_remote_otel_dir = remote_base. join ( OLD_SUB_AGENT_DATA_DIR ) . join ( OTEL_AGENT_ID ) ;
232- if old_remote_otel_dir. exists ( ) && old_remote_otel_dir . is_dir ( ) {
232+ if old_remote_otel_dir. exists ( ) {
233233 debug ! (
234234 "Found old remote nrdot directory, adding to migration: {}" ,
235235 old_remote_otel_dir. display( )
@@ -300,21 +300,6 @@ mod tests {
300300 assert ! ( exists) ;
301301 }
302302
303- #[ test]
304- fn test_check_new_folders_false_if_one_is_missing ( ) {
305- let temp_dir = tempdir ( ) . unwrap ( ) ;
306- let local_base = temp_dir. path ( ) . join ( "local" ) ;
307- let data_base = temp_dir. path ( ) . join ( "data" ) ;
308-
309- let local_new_path = local_base. join ( FOLDER_NAME_LOCAL_DATA ) ;
310- let remote_new_path = data_base. join ( FOLDER_NAME_FLEET_DATA ) ;
311-
312- fs:: create_dir_all ( & local_new_path) . unwrap ( ) ;
313-
314- let exists = check_new_folders ( & local_new_path, & remote_new_path) ;
315- assert ! ( !exists) ;
316- }
317-
318303 #[ test]
319304 fn test_move_item_success ( ) {
320305 let temp_dir = tempdir ( ) . unwrap ( ) ;
0 commit comments