1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-07 01:54:26 +01:00

Removed, no more needed, LibraryInstaller::updateIndex method

This commit is contained in:
Cristian Maglie 2019-12-06 15:05:27 +01:00
parent 0056cbc545
commit 401fe65418
3 changed files with 8 additions and 52 deletions

View File

@ -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
}

View File

@ -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);
}

View File

@ -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<ContributedLibraryRelease> libs = new ArrayList<>();
libs.add(lib);