11package edu .wpi .first .wpilib .opencv .installer ;
22
33import edu .wpi .first .wpilib .opencv .installer .platform .Platform ;
4+
45import lombok .experimental .UtilityClass ;
56
67import java .io .File ;
@@ -143,12 +144,6 @@ private static void install(ArtifactType type, String location) throws IOExcepti
143144 // Force location to be an absolute path
144145 location = Paths .get (location ).toAbsolutePath ().toString ();
145146 }
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- }
152147 String artifactId ;
153148 String v = openCvVersion ;
154149 String classifier = null ;
@@ -199,9 +194,6 @@ private static void install(ArtifactType type, String location) throws IOExcepti
199194 unzipped = dst .getParent ();
200195 }
201196 copyAll (unzipped , Paths .get (installLocation ));
202- if (!overridePlatform ) {
203- InstallChecker .registerSuccessfulInstall (type , location , openCvVersion );
204- }
205197 }
206198
207199 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 {
272264
273265 private static void unsafeCopy (Path src , Path dst ) {
274266 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 {
276273 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 );
287277 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" );
288282 }
289283 }
290284 } catch (IOException e ) {
@@ -310,7 +304,7 @@ private static Path copyToMavenLocal(String repo, String artifactId, String vers
310304 Files .deleteIfExists (Paths .get (dstDir , jar ));
311305 Files .copy (new URL (jarPath ).openStream (), Paths .get (dstDir , jar ));
312306
313- String pom = String .format ("%s-%s.pom" , artifactId , version );
307+ String pom = String .format ("%s-%s.pom" , artifactId , version );
314308 String pomPath = remoteDir + '/' + pom ;
315309 Files .deleteIfExists (Paths .get (dstDir , pom ));
316310 Files .copy (new URL (pomPath ).openStream (), Paths .get (dstDir , pom ));
0 commit comments