File tree 1 file changed +19
-0
lines changed
java/src/org/openqa/selenium/manager
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -71,13 +71,31 @@ public class SeleniumManager {
71
71
private final String managerPath = System .getenv ("SE_MANAGER_PATH" );
72
72
private Path binary = managerPath == null ? null : Paths .get (managerPath );
73
73
private String seleniumManagerVersion ;
74
+ private boolean binaryInTemporalFolder = false ;
74
75
75
76
/** Wrapper for the Selenium Manager binary. */
76
77
private SeleniumManager () {
77
78
BuildInfo info = new BuildInfo ();
78
79
String releaseLabel = info .getReleaseLabel ();
79
80
int lastDot = releaseLabel .lastIndexOf ("." );
80
81
seleniumManagerVersion = BETA_PREFIX + releaseLabel .substring (0 , lastDot );
82
+ if (managerPath == null ) {
83
+ Runtime .getRuntime ()
84
+ .addShutdownHook (
85
+ new Thread (
86
+ () -> {
87
+ if (binaryInTemporalFolder && binary != null && Files .exists (binary )) {
88
+ try {
89
+ Files .delete (binary );
90
+ } catch (IOException e ) {
91
+ LOG .warning (
92
+ String .format (
93
+ "%s deleting temporal file: %s" ,
94
+ e .getClass ().getSimpleName (), e .getMessage ()));
95
+ }
96
+ }
97
+ }));
98
+ }
81
99
}
82
100
83
101
public static SeleniumManager getInstance () {
@@ -298,6 +316,7 @@ private Path getBinaryInCache(String binaryName) throws IOException {
298
316
Path cacheParent = Paths .get (cachePath );
299
317
if (!Files .isWritable (cacheParent )) {
300
318
cacheParent = Files .createTempDirectory (SELENIUM_MANAGER );
319
+ binaryInTemporalFolder = true ;
301
320
}
302
321
303
322
return Paths .get (
You can’t perform that action at this time.
0 commit comments