1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-19 08:52:15 +01:00

ContributionsIndexer now has bundled hardware path as a field

This commit is contained in:
Cristian Maglie 2016-08-11 10:41:48 +02:00
parent 9669d67e16
commit 7008f6c57c
3 changed files with 17 additions and 12 deletions

View File

@ -344,13 +344,15 @@ public class Base {
PreferencesData.save();
if (parser.isInstallBoard()) {
ContributionsIndexer indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder(), BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
ContributionsIndexer indexer = new ContributionsIndexer(
BaseNoGui.getSettingsFolder(), BaseNoGui.getHardwareFolder(),
BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
ProgressListener progressListener = new ConsoleProgressListener();
List<String> downloadedPackageIndexFiles = contributionInstaller.updateIndex(progressListener);
contributionInstaller.deleteUnknownFiles(downloadedPackageIndexFiles);
indexer.parseIndex();
indexer.syncWithFilesystem(BaseNoGui.getHardwareFolder());
indexer.syncWithFilesystem();
String[] boardToInstallParts = parser.getBoardToInstall().split(":");

View File

@ -66,12 +66,14 @@ public class ContributionsIndexer {
private final File packagesFolder;
private final File stagingFolder;
private final File preferencesFolder;
private final File builtInHardwareFolder;
private final Platform platform;
private final SignatureVerifier signatureVerifier;
private ContributionsIndex index;
public ContributionsIndexer(File preferencesFolder, Platform platform, SignatureVerifier signatureVerifier) {
public ContributionsIndexer(File preferencesFolder, File builtInHardwareFolder, Platform platform, SignatureVerifier signatureVerifier) {
this.preferencesFolder = preferencesFolder;
this.builtInHardwareFolder = builtInHardwareFolder;
this.platform = platform;
this.signatureVerifier = signatureVerifier;
packagesFolder = new File(preferencesFolder, "packages");
@ -188,22 +190,22 @@ public class ContributionsIndexer {
}
}
public void syncWithFilesystem(File hardwareFolder) throws IOException {
syncBuiltInHardwareFolder(hardwareFolder);
public void syncWithFilesystem() throws IOException {
syncBuiltInHardware();
syncLocalPackagesFolder();
syncLocalPackages();
}
private void syncBuiltInHardwareFolder(File hardwareFolder) throws IOException {
private void syncBuiltInHardware() throws IOException {
if (index == null) {
return;
}
for (File folder : hardwareFolder.listFiles(ONLY_DIRS)) {
for (File folder : builtInHardwareFolder.listFiles(ONLY_DIRS)) {
ContributedPackage pack = index.findPackage(folder.getName());
if (pack != null) {
syncBuiltInPackageWithFilesystem(pack, folder);
File toolsFolder = new File(hardwareFolder, "tools");
File toolsFolder = new File(builtInHardwareFolder, "tools");
if (toolsFolder.isDirectory()) {
for (File toolFolder : toolsFolder.listFiles(ONLY_DIRS)) {
File builtInToolsMetadata = new File(toolFolder, "builtin_tools_versions.txt");
@ -231,7 +233,7 @@ public class ContributionsIndexer {
}
}
private void syncLocalPackagesFolder() {
private void syncLocalPackages() {
if (!packagesFolder.isDirectory()) {
return;
}

View File

@ -608,7 +608,8 @@ public class BaseNoGui {
}
static public void initPackages() throws Exception {
indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder(), BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
indexer = new ContributionsIndexer(getSettingsFolder(), getHardwareFolder(), getPlatform(),
new GPGDetachedSignatureVerifier());
File indexFile = indexer.getIndexFile("package_index.json");
File defaultPackageJsonFile = new File(getContentFile("dist"), "package_index.json");
if (!indexFile.isFile() || (defaultPackageJsonFile.isFile() && defaultPackageJsonFile.lastModified() > indexFile.lastModified())) {
@ -637,7 +638,7 @@ public class BaseNoGui {
FileUtils.deleteIfExists(indexSignatureFile);
throw e;
}
indexer.syncWithFilesystem(getHardwareFolder());
indexer.syncWithFilesystem();
packages = new LinkedHashMap<String, TargetPackage>();
loadHardware(getHardwareFolder());