mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 516407 Set Agent and make package.json downloads more robust
The ESP8266 URL started reject connections. Turns out setting the User-Agent property on the connection fixes that. I also made this more robust from download failures so that at least other packages can be downloaded. Finally, I removed the ESP8266 URL from the defaults. Change-Id: Ib2ea5667ba490ae660883a30b3049c3d736cfdb7
This commit is contained in:
parent
43e62924a1
commit
822e0d0505
2 changed files with 6 additions and 3 deletions
|
@ -26,7 +26,6 @@ public class ArduinoPreferences {
|
|||
|
||||
private static final String defaultHome = Paths.get(System.getProperty("user.home"), ".arduinocdt").toString(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
private static final String defaultBoardUrls = "http://downloads.arduino.cc/packages/package_index.json" //$NON-NLS-1$
|
||||
+ "\nhttp://arduino.esp8266.com/stable/package_esp8266com_index.json" //$NON-NLS-1$
|
||||
+ "\nhttps://adafruit.github.io/arduino-board-index/package_adafruit_index.json"; //$NON-NLS-1$
|
||||
|
||||
private static IEclipsePreferences getPrefs() {
|
||||
|
|
|
@ -200,11 +200,15 @@ public class ArduinoManager {
|
|||
Path packagePath = ArduinoPreferences.getArduinoHome().resolve(Paths.get(url.getPath()).getFileName());
|
||||
try {
|
||||
Files.createDirectories(ArduinoPreferences.getArduinoHome());
|
||||
try (InputStream in = url.openStream()) {
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.setRequestProperty("User-Agent", //$NON-NLS-1$
|
||||
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2"); //$NON-NLS-1$
|
||||
try (InputStream in = connection.getInputStream()) {
|
||||
Files.copy(in, packagePath, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw Activator.coreException(String.format("Error loading %s", url.toString()), e); //$NON-NLS-1$
|
||||
// Log and continue, URLs sometimes come and go
|
||||
Activator.log(e);
|
||||
}
|
||||
sub.worked(1);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue