1
1
package edu .wpi .first .wpilib .opencv .installer ;
2
2
3
3
import edu .wpi .first .wpilib .opencv .installer .platform .Platform ;
4
+
4
5
import lombok .experimental .UtilityClass ;
5
6
6
7
import java .io .File ;
@@ -143,12 +144,6 @@ private static void install(ArtifactType type, String location) throws IOExcepti
143
144
// Force location to be an absolute path
144
145
location = Paths .get (location ).toAbsolutePath ().toString ();
145
146
}
146
- if (!overridePlatform && InstallChecker .isInstalled (type , location , openCvVersion )) {
147
- System .out .println ("Artifacts for the version " + openCvVersion + " " + type .getArtifactName () + " have already been installed!" );
148
- if (!overwrite ) {
149
- return ;
150
- }
151
- }
152
147
String artifactId ;
153
148
String v = openCvVersion ;
154
149
String classifier = null ;
@@ -199,9 +194,6 @@ private static void install(ArtifactType type, String location) throws IOExcepti
199
194
unzipped = dst .getParent ();
200
195
}
201
196
copyAll (unzipped , Paths .get (installLocation ));
202
- if (!overridePlatform ) {
203
- InstallChecker .registerSuccessfulInstall (type , location , openCvVersion );
204
- }
205
197
}
206
198
207
199
private static URL resolveRemote (String artifactId , String version , String classifier ) throws MalformedURLException {
@@ -272,19 +264,21 @@ private static void copyAll(Path sourceDir, Path dstDir) throws IOException {
272
264
273
265
private static void unsafeCopy (Path src , Path dst ) {
274
266
try {
275
- if (overwrite ) {
267
+ if (dst .getParent () != null && !Files .exists (dst .getParent ())) {
268
+ Files .createDirectories (dst .getParent ());
269
+ }
270
+ if (Files .isDirectory (src )) {
271
+ copyAll (src , dst );
272
+ } else {
276
273
System .out .println (" Copying " + src .toAbsolutePath () + " to " + dst .toAbsolutePath ());
277
- if (dst .getParent () != null && !Files .exists (dst .getParent ())) {
278
- Files .createDirectories (dst .getParent ());
279
- }
280
- if (Files .isDirectory (src )) {
281
- copyAll (src , dst );
282
- } else {
283
- if (Files .exists (dst )) {
284
- System .out .println (" Destination file already exists, overwriting" );
285
- Files .delete (dst );
286
- }
274
+ if (Files .exists (dst ) && overwrite ) {
275
+ System .out .println (" Destination file already exists, overwriting" );
276
+ Files .delete (dst );
287
277
Files .copy (src , dst );
278
+ } else if (!(Files .exists (dst ))) {
279
+ Files .copy (src , dst );
280
+ } else {
281
+ System .out .println (" Destination file already exists, aborting copy" );
288
282
}
289
283
}
290
284
} catch (IOException e ) {
@@ -310,7 +304,7 @@ private static Path copyToMavenLocal(String repo, String artifactId, String vers
310
304
Files .deleteIfExists (Paths .get (dstDir , jar ));
311
305
Files .copy (new URL (jarPath ).openStream (), Paths .get (dstDir , jar ));
312
306
313
- String pom = String .format ("%s-%s.pom" , artifactId , version );
307
+ String pom = String .format ("%s-%s.pom" , artifactId , version );
314
308
String pomPath = remoteDir + '/' + pom ;
315
309
Files .deleteIfExists (Paths .get (dstDir , pom ));
316
310
Files .copy (new URL (pomPath ).openStream (), Paths .get (dstDir , pom ));
0 commit comments