@@ -318,6 +318,12 @@ private void addTests(Path originalTestsLocation){
318
318
.resolve ("java" );
319
319
Path allTests = originalTestsLocation .resolve ("." );
320
320
321
+ ensureFileBelongsToProject (destination );
322
+ boolean shouldDelete = InteractiveTaskUtils .askForDeletePermission (destination );
323
+ if (!shouldDelete ) {
324
+ throw new RuntimeException ("The task didn't get permission to delete dummy stubs. Cannot proceed with the task execution" );
325
+ }
326
+
321
327
InteractiveTaskUtils .printUserInfo ("Removing dummy test stubs" );
322
328
invokeCommand ("rm -r " + destination , "Cannot delete files from: " + destination );
323
329
@@ -504,18 +510,24 @@ private void removeEmptyConfigFiles() throws IOException {
504
510
if (Files .exists (agentExtractedPredefinedClasses )) {
505
511
File [] extractedPredefinedClasses = new File (agentExtractedPredefinedClasses .toUri ()).listFiles ();
506
512
if (extractedPredefinedClasses == null || extractedPredefinedClasses .length == 0 ) {
507
- InteractiveTaskUtils .printUserInfo ("Removing empty: agent-extracted-predefined-classes" );
508
- invokeCommand ("rm -r " + agentExtractedPredefinedClasses , "Cannot delete empty config file: " + agentExtractedPredefinedClasses );
513
+ boolean canDelete = InteractiveTaskUtils .askForDeletePermission (agentExtractedPredefinedClasses );
514
+ if (canDelete ) {
515
+ InteractiveTaskUtils .printUserInfo ("Removing empty: agent-extracted-predefined-classes" );
516
+ invokeCommand ("rm -r " + agentExtractedPredefinedClasses , "Cannot delete empty config file: " + agentExtractedPredefinedClasses );
517
+ }
509
518
}
510
519
}
511
520
512
521
trimIndexFile (indexFile , remainingFiles );
513
522
}
514
523
515
524
private void removeConfigFile (Path path , CONFIG_FILES file , List <CONFIG_FILES > remainingFiles ) {
516
- InteractiveTaskUtils .printUserInfo ("Removing empty: " + file .get ());
517
- invokeCommand ("rm " + path , "Cannot delete empty config file: " + path );
518
- remainingFiles .remove (file );
525
+ boolean canDelete = InteractiveTaskUtils .askForDeletePermission (path );
526
+ if (canDelete ) {
527
+ InteractiveTaskUtils .printUserInfo ("Removing empty: " + file .get ());
528
+ invokeCommand ("rm " + path , "Cannot delete empty config file: " + path );
529
+ remainingFiles .remove (file );
530
+ }
519
531
}
520
532
521
533
private void trimIndexFile (Path index , List <CONFIG_FILES > remainingFiles ) throws IOException {
@@ -592,4 +604,10 @@ private void invokeCommand(String executable, List<String> args, String errorMes
592
604
throw new RuntimeException (errorMessage + ". See: " + execOutput );
593
605
}
594
606
}
607
+
608
+ private void ensureFileBelongsToProject (Path file ) {
609
+ if (!file .startsWith (getProject ().getProjectDir ().getAbsolutePath ())) {
610
+ throw new RuntimeException ("The following file doesn't belong to the metadata repository: " + file );
611
+ }
612
+ }
595
613
}
0 commit comments