From 7008f6c57c11a2f6da585d9961b72ff27b461789 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 11 Aug 2016 10:41:48 +0200 Subject: [PATCH] ContributionsIndexer now has bundled hardware path as a field --- app/src/processing/app/Base.java | 6 ++++-- .../packages/ContributionsIndexer.java | 18 ++++++++++-------- arduino-core/src/processing/app/BaseNoGui.java | 5 +++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index d45d9c638..95becc3b0 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -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 downloadedPackageIndexFiles = contributionInstaller.updateIndex(progressListener); contributionInstaller.deleteUnknownFiles(downloadedPackageIndexFiles); indexer.parseIndex(); - indexer.syncWithFilesystem(BaseNoGui.getHardwareFolder()); + indexer.syncWithFilesystem(); String[] boardToInstallParts = parser.getBoardToInstall().split(":"); diff --git a/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java b/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java index 5e8fb03ab..917d94014 100644 --- a/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java +++ b/arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java @@ -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; } diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java index 43b99aff8..1cef43cbf 100644 --- a/arduino-core/src/processing/app/BaseNoGui.java +++ b/arduino-core/src/processing/app/BaseNoGui.java @@ -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(); loadHardware(getHardwareFolder());