diff --git a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java index 4b4fb7f7d..ef1729b6c 100644 --- a/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java +++ b/arduino-core/src/cc/arduino/contributions/libraries/LibraryInstaller.java @@ -87,6 +87,16 @@ public class LibraryInstaller { } public synchronized void install(ContributedLibrary lib, Optional mayReplacedLib, ProgressListener progressListener) throws Exception { + final MultiStepProgress progress = new MultiStepProgress(4); + + // Do install library (3 steps) + performInstall(lib, mayReplacedLib, progressListener, progress); + + // Rescan index (1 step) + rescanLibraryIndex(progress, progressListener); + } + + private void performInstall(ContributedLibrary lib, Optional mayReplacedLib, ProgressListener progressListener, MultiStepProgress progress) throws Exception { if (lib.isLibraryInstalled()) { System.out.println(I18n.format(tr("Library is already installed: {0}:{1}"), lib.getName(), lib.getParsedVersion())); return; @@ -94,8 +104,6 @@ public class LibraryInstaller { DownloadableContributionsDownloader downloader = new DownloadableContributionsDownloader(BaseNoGui.librariesIndexer.getStagingFolder()); - final MultiStepProgress progress = new MultiStepProgress(3); - // Step 1: Download library try { downloader.download(lib, progress, I18n.format(tr("Downloading library: {0}"), lib.getName()), progressListener); @@ -103,6 +111,7 @@ public class LibraryInstaller { // Download interrupted... just exit return; } + progress.stepDone(); // TODO: Extract to temporary folders and move to the final destination only // once everything is successfully unpacked. If the operation fails remove @@ -129,9 +138,6 @@ public class LibraryInstaller { File destFolder = new File(libsFolder, lib.getName().replaceAll(" ", "_")); tmpFolder.renameTo(destFolder); progress.stepDone(); - - // Step 4: Rescan index - rescanLibraryIndex(progress, progressListener); } public synchronized void remove(ContributedLibrary lib, ProgressListener progressListener) throws IOException {