From 401fe654187fb60fdc5c533d1781a429142a7a71 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Fri, 6 Dec 2019 15:05:27 +0100 Subject: [PATCH] Removed, no more needed, LibraryInstaller::updateIndex method --- .../contributions/ContributionsSelfCheck.java | 14 +++--- app/src/processing/app/Base.java | 2 +- .../libraries/LibraryInstaller.java | 44 ------------------- 3 files changed, 8 insertions(+), 52 deletions(-) diff --git a/app/src/cc/arduino/contributions/ContributionsSelfCheck.java b/app/src/cc/arduino/contributions/ContributionsSelfCheck.java index 96fd987b0..0c146d4f6 100644 --- a/app/src/cc/arduino/contributions/ContributionsSelfCheck.java +++ b/app/src/cc/arduino/contributions/ContributionsSelfCheck.java @@ -30,7 +30,7 @@ package cc.arduino.contributions; import cc.arduino.UpdatableBoardsLibsFakeURLsHandler; -import cc.arduino.contributions.libraries.LibraryInstaller; +import cc.arduino.cli.ArduinoCoreInstance; import cc.arduino.contributions.libraries.filters.UpdatableLibraryPredicate; import cc.arduino.contributions.packages.ContributionInstaller; import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate; @@ -53,7 +53,7 @@ public class ContributionsSelfCheck extends TimerTask implements NotificationPop private final Base base; private final HyperlinkListener hyperlinkListener; private final ContributionInstaller contributionInstaller; - private final LibraryInstaller libraryInstaller; + private final ArduinoCoreInstance core; private final ProgressListener progressListener; private final String boardsManagerURL = "http://boardsmanager/DropdownUpdatableCoresItem"; private final String libraryManagerURL = "http://librarymanager/DropdownUpdatableLibrariesItem"; @@ -61,11 +61,11 @@ public class ContributionsSelfCheck extends TimerTask implements NotificationPop private volatile boolean cancelled; private volatile NotificationPopup notificationPopup; - public ContributionsSelfCheck(Base base, HyperlinkListener hyperlinkListener, ContributionInstaller contributionInstaller, LibraryInstaller libraryInstaller) { + public ContributionsSelfCheck(Base base, HyperlinkListener hyperlinkListener, ContributionInstaller contributionInstaller, ArduinoCoreInstance core) { this.base = base; this.hyperlinkListener = hyperlinkListener; this.contributionInstaller = contributionInstaller; - this.libraryInstaller = libraryInstaller; + this.core = core; this.progressListener = new NoopProgressListener(); this.cancelled = false; } @@ -176,13 +176,13 @@ public class ContributionsSelfCheck extends TimerTask implements NotificationPop goToManager(libraryManagerURL); } - static boolean checkForUpdatablePlatforms() { + boolean checkForUpdatablePlatforms() { return BaseNoGui.indexer.getPackages().stream() .flatMap(pack -> pack.getPlatforms().stream()) .anyMatch(new UpdatablePlatformPredicate()); } - static boolean checkForUpdatableLibraries() { + boolean checkForUpdatableLibraries() { return BaseNoGui.librariesIndexer.getIndex().getLibraries().stream() .anyMatch(new UpdatableLibraryPredicate()); } @@ -201,7 +201,7 @@ public class ContributionsSelfCheck extends TimerTask implements NotificationPop return; } try { - libraryInstaller.updateIndex(progressListener); + core.updateLibrariesIndex(progressListener); } catch (Exception e) { // ignore } diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index e1aed37e4..e0a1bc175 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -509,7 +509,7 @@ public class Base { if (PreferencesData.getBoolean("update.check")) { new UpdateCheck(this); - contributionsSelfCheck = new ContributionsSelfCheck(this, new UpdatableBoardsLibsFakeURLsHandler(this), contributionInstaller, libraryInstaller); + contributionsSelfCheck = new ContributionsSelfCheck(this, new UpdatableBoardsLibsFakeURLsHandler(this), contributionInstaller, BaseNoGui.getArduinoCoreService()); new Timer(false).schedule(contributionsSelfCheck, Constants.BOARDS_LIBS_UPDATABLE_CHECK_START_PERIOD); } diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java index 6b5a6f2ad..d7ce827cc 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java @@ -65,50 +65,6 @@ public class LibraryInstaller { this.platform = platform; } - public synchronized void updateIndex(ProgressListener progressListener) throws Exception { - /* - final MultiStepProgress progress = new MultiStepProgress(3); - DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.librariesIndexer.getStagingFolder()); - // Step 1: Download index - File outputFile = BaseNoGui.librariesIndexer.getIndexFile(); - // Create temp files - String signatureFileName = FilenameUtils.getName(new URL(Constants.LIBRARY_INDEX_URL).getPath()); - File libraryIndexTemp = File.createTempFile(signatureFileName, ".tmp"); - final URL libraryURL = new URL(Constants.LIBRARY_INDEX_URL); - final URL libraryGzURL = new URL(Constants.LIBRARY_INDEX_URL_GZ); - final String statusText = tr("Downloading libraries index..."); - try { - GZippedJsonDownloader gZippedJsonDownloader = new GZippedJsonDownloader(downloader, libraryURL, libraryGzURL); - gZippedJsonDownloader.download(libraryIndexTemp, progress, statusText, progressListener, true); - } catch (InterruptedException e) { - // Download interrupted... just exit - return; - } - progress.stepDone(); - - URL signatureUrl = new URL(libraryURL.toString() + ".sig"); - if (downloader.verifyDomain(signatureUrl)) { - if (downloader.checkSignature(progress, signatureUrl, progressListener, signatureVerifier, statusText, libraryIndexTemp)) { - // Replace old index with the updated one - if (libraryIndexTemp.length() > 0) { - Files.move(libraryIndexTemp.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING); - } - } else { - FileDownloader.invalidateFiles(libraryGzURL, libraryURL, signatureUrl); - log.error("Fail to verify the signature of {} the cached files have been removed", libraryURL); - } - } else { - log.info("The domain is not selected to verify the signature. library index: {}", signatureUrl); - } - - // Step 2: Parse index - BaseNoGui.librariesIndexer.regenerateIndex(); - - // Step 3: Rescan index - rescanLibraryIndex(progress, progressListener); - */ - } - public void install(ContributedLibraryRelease lib, ProgressListener progressListener) throws Exception { ArrayList libs = new ArrayList<>(); libs.add(lib);