Skip to content

Commit 84eda4a

Browse files
committed
Fixed to throw an error when cannot download image
1 parent ce444fa commit 84eda4a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/main/java/com/formkiq/gradle/internal/Downloader.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
package com.formkiq.gradle.internal;
1616

17+
import java.io.FileNotFoundException;
1718
import java.io.FileOutputStream;
1819
import java.io.IOException;
1920
import java.io.InputStream;
@@ -42,11 +43,13 @@ public class Downloader {
4243
*/
4344
public void download(final Collection<String> urls, final Path toFile) throws IOException {
4445

46+
boolean found = false;
4547
if (!toFile.toFile().exists()) {
4648

4749
for (final String url : urls) {
4850

4951
if (urlExists(url)) {
52+
found = true;
5053
LOGGER.log(Level.INFO, "Downloading " + url + " to " + toFile);
5154
Path parent = toFile.getParent();
5255
if (parent != null) {
@@ -71,6 +74,10 @@ public void download(final Collection<String> urls, final Path toFile) throws IO
7174
} else {
7275
LOGGER.log(Level.INFO, "Downloaded file {0} already exists", toFile);
7376
}
77+
78+
if (!found) {
79+
throw new FileNotFoundException("Failed to download file from urls " + urls);
80+
}
7481
}
7582

7683
/**

0 commit comments

Comments
 (0)