mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
ContributedPlatform.getResolvedTools returns a copy of the original list (otherwise violating inner state)
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
package processing.app;
|
||||
package cc.arduino;
|
||||
|
||||
public class DefaultUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
System.out.println(t);
|
||||
System.out.println(e);
|
||||
System.err.println(t);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
@ -30,6 +30,7 @@ package cc.arduino.packages.contributions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ContributedPlatform extends DownloadableContribution {
|
||||
@ -53,7 +54,10 @@ public abstract class ContributedPlatform extends DownloadableContribution {
|
||||
private ContributedPackage parentPackage;
|
||||
|
||||
public List<ContributedTool> getResolvedTools() {
|
||||
return resolvedTools;
|
||||
if (resolvedTools == null) {
|
||||
return null;
|
||||
}
|
||||
return new LinkedList<ContributedTool>(resolvedTools);
|
||||
}
|
||||
|
||||
public List<ContributedTool> resolveToolsDependencies(Collection<ContributedPackage> packages) {
|
||||
@ -68,8 +72,7 @@ public abstract class ContributedPlatform extends DownloadableContribution {
|
||||
// Search the referenced tool
|
||||
ContributedTool tool = dep.resolve(packages);
|
||||
if (tool == null) {
|
||||
System.err
|
||||
.println("Index error: could not find referenced tool " + dep);
|
||||
System.err.println("Index error: could not find referenced tool " + dep);
|
||||
}
|
||||
resolvedTools.add(tool);
|
||||
}
|
||||
|
@ -28,8 +28,10 @@
|
||||
*/
|
||||
package cc.arduino.packages.contributions;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
import cc.arduino.utils.ArchiveExtractor;
|
||||
import cc.arduino.utils.MultiStepProgress;
|
||||
import cc.arduino.utils.Progress;
|
||||
import processing.app.helpers.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
@ -37,10 +39,8 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import processing.app.helpers.FileUtils;
|
||||
import cc.arduino.utils.ArchiveExtractor;
|
||||
import cc.arduino.utils.MultiStepProgress;
|
||||
import cc.arduino.utils.Progress;
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
|
||||
public class ContributionInstaller {
|
||||
|
||||
@ -55,7 +55,7 @@ public class ContributionInstaller {
|
||||
@Override
|
||||
protected void onProgress(Progress progress) {
|
||||
ContributionInstaller.this.onProgress(progress);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -84,8 +84,7 @@ public class ContributionInstaller {
|
||||
// Download all
|
||||
try {
|
||||
// Download platform
|
||||
downloader.download(platform, progress,
|
||||
_("Downloading boards definitions."));
|
||||
downloader.download(platform, progress, _("Downloading boards definitions."));
|
||||
progress.stepDone();
|
||||
|
||||
// Download tools
|
||||
@ -111,7 +110,7 @@ public class ContributionInstaller {
|
||||
// Unzip tools on the correct location
|
||||
File toolsFolder = new File(packageFolder, "tools");
|
||||
int i = 1;
|
||||
for (ContributedTool tool : platform.getResolvedTools()) {
|
||||
for (ContributedTool tool : tools) {
|
||||
progress.setStatus(format(_("Installing tools ({0}/{1})..."), i, tools.size()));
|
||||
onProgress(progress);
|
||||
i++;
|
||||
@ -119,6 +118,7 @@ public class ContributionInstaller {
|
||||
File destFolder = new File(toolsFolder, tool.getName() + File.separator + tool.getVersion());
|
||||
|
||||
destFolder.mkdirs();
|
||||
assert toolContrib.getDownloadedFile() != null;
|
||||
ArchiveExtractor.extract(toolContrib.getDownloadedFile(), destFolder, 1);
|
||||
toolContrib.setInstalled(true);
|
||||
toolContrib.setInstalledFolder(destFolder);
|
||||
@ -147,8 +147,9 @@ public class ContributionInstaller {
|
||||
|
||||
// Check if the tools are no longer needed
|
||||
for (ContributedTool tool : platform.getResolvedTools()) {
|
||||
if (indexer.isContributedToolUsed(tool))
|
||||
if (indexer.isContributedToolUsed(tool)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DownloadableContribution toolContrib = tool.getDownloadableContribution();
|
||||
File destFolder = toolContrib.getInstalledFolder();
|
||||
|
@ -28,17 +28,17 @@
|
||||
*/
|
||||
package cc.arduino.packages.contributions;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
import cc.arduino.utils.FileHash;
|
||||
import cc.arduino.utils.Progress;
|
||||
import cc.arduino.utils.network.FileDownloader;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import cc.arduino.utils.FileHash;
|
||||
import cc.arduino.utils.Progress;
|
||||
import cc.arduino.utils.network.FileDownloader;
|
||||
import static processing.app.I18n._;
|
||||
import static processing.app.I18n.format;
|
||||
|
||||
public class DownloadableContributionsDownloader {
|
||||
|
||||
@ -50,7 +50,7 @@ public class DownloadableContributionsDownloader {
|
||||
|
||||
public File download(DownloadableContribution contribution,
|
||||
final Progress progress, final String statusText)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
URL url = new URL(contribution.getUrl());
|
||||
final File outputFile = new File(stagingFolder, contribution.getArchiveFileName());
|
||||
|
||||
@ -67,8 +67,9 @@ public class DownloadableContributionsDownloader {
|
||||
onProgress(progress);
|
||||
String checksum = contribution.getChecksum();
|
||||
String algo = checksum.split(":")[0];
|
||||
if (!FileHash.hash(outputFile, algo).equals(checksum))
|
||||
if (!FileHash.hash(outputFile, algo).equals(checksum)) {
|
||||
throw new Exception(_("CRC doesn't match. File is corrupted."));
|
||||
}
|
||||
|
||||
contribution.setDownloaded(true);
|
||||
contribution.setDownloadedFile(outputFile);
|
||||
@ -94,9 +95,9 @@ public class DownloadableContributionsDownloader {
|
||||
}
|
||||
});
|
||||
downloader.download();
|
||||
if (!downloader.isCompleted())
|
||||
throw new Exception(format(_("Error dowloading {0}"), url),
|
||||
downloader.getError());
|
||||
if (!downloader.isCompleted()) {
|
||||
throw new Exception(format(_("Error dowloading {0}"), url), downloader.getError());
|
||||
}
|
||||
}
|
||||
|
||||
protected void onProgress(Progress progress) {
|
||||
|
@ -13,6 +13,7 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import cc.arduino.DefaultUncaughtExceptionHandler;
|
||||
import org.apache.commons.logging.impl.LogFactoryImpl;
|
||||
import org.apache.commons.logging.impl.NoOpLog;
|
||||
|
||||
@ -712,6 +713,8 @@ public class BaseNoGui {
|
||||
if (args.length == 0)
|
||||
showError(_("No parameters"), _("No command line parameters found"), null);
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler());
|
||||
|
||||
initPlatform();
|
||||
|
||||
initPortableFolder();
|
||||
@ -719,8 +722,6 @@ public class BaseNoGui {
|
||||
initParameters(args);
|
||||
|
||||
init(args);
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler());
|
||||
}
|
||||
|
||||
static public void onBoardOrPortChange() {
|
||||
|
Reference in New Issue
Block a user