Skip to content

Commit 4f6eda8

Browse files
author
SOekd
committed
fixed issue involving already downloaded
1 parent 5ee5944 commit 4f6eda8

File tree

1 file changed

+6
-5
lines changed
  • src/main/java/app/miyuki/miyukidependencydownloader/downloader

1 file changed

+6
-5
lines changed

src/main/java/app/miyuki/miyukidependencydownloader/downloader/Downloader.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ protected boolean download(@NotNull Dependency dependency, @NotNull Repository r
6161
if (dependencyUrl == null)
6262
return false;
6363

64+
val dependencyPath = dependency.getDownloadPath(defaultPath);
65+
if (Files.exists(dependencyPath))
66+
return true;
67+
6468
HttpURLConnection connection = null;
6569
try {
70+
6671
val url = new URL(dependencyUrl);
6772
connection = (HttpURLConnection) url.openConnection();
6873
connection.setConnectTimeout(20000);
@@ -73,15 +78,11 @@ protected boolean download(@NotNull Dependency dependency, @NotNull Repository r
7378

7479
@Cleanup val inputStream = new BufferedInputStream(connection.getInputStream());
7580

76-
val dependencyPath = dependency.getDownloadPath(defaultPath);
77-
7881
val dependencyFolder = dependencyPath.getParent();
7982
if (Files.notExists(dependencyFolder))
8083
Files.createDirectories(dependencyFolder);
8184

82-
83-
if (Files.notExists(dependencyPath))
84-
Files.copy(inputStream, dependencyPath);
85+
Files.copy(inputStream, dependencyPath);
8586
return true;
8687
} catch (IOException exception) {
8788
return false;

0 commit comments

Comments
 (0)