Skip to content

Commit 4344ce8

Browse files
authored
Merge pull request #745 from Sloeber/release_4.1
#743 try download from baeyens.it first
2 parents 602236b + 75d81a0 commit 4344ce8

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

io.sloeber.core/src/io/sloeber/core/managers/Manager.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,18 @@ public static File getLocalFileName(String url) {
196196
return packagePath.toFile();
197197
}
198198

199+
/**
200+
* convert a local file name to a baeyens it alternative download name There
201+
* is no check wether the file exists only a conversion
202+
*
203+
* @param url
204+
* url of the file we want a local
205+
* @return the file that represents the file on Baeyens.it
206+
*/
207+
private static String getBaeyensItAlternativeDownload(String localFileName) {
208+
return "http://eclipse.baeyens.it/download/" + localFileName; //$NON-NLS-1$
209+
}
210+
199211
/**
200212
* This method takes a json boards file url and downloads it and parses it
201213
* for usage in the boards manager
@@ -213,10 +225,15 @@ static private void loadJson(String url, boolean forceDownload) {
213225
}
214226
if (!jsonFile.exists() || forceDownload) {
215227
jsonFile.getParentFile().mkdirs();
228+
String alternativeDownloadurl = getBaeyensItAlternativeDownload(jsonFile.getName());
216229
try {
217-
myCopy(new URL(url.trim()), jsonFile);
218-
} catch (IOException e) {
219-
Common.log(new Status(IStatus.ERROR, Activator.getId(), "Unable to download " + url, e)); //$NON-NLS-1$
230+
myCopy(new URL(alternativeDownloadurl.trim()), jsonFile);
231+
} catch (IOException e0) {
232+
try {
233+
myCopy(new URL(url.trim()), jsonFile);
234+
} catch (IOException e) {
235+
Common.log(new Status(IStatus.ERROR, Activator.getId(), "Unable to download " + url, e)); //$NON-NLS-1$
236+
}
220237
}
221238
}
222239
if (jsonFile.exists()) {

0 commit comments

Comments
 (0)