From f7a63a5e651304e0b2f317110ba18a2e643b4d0a Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 11 Apr 2016 13:33:06 -0700 Subject: [PATCH] Plugin cli: Add verbose output with zip url when installing plugin closes #17529 --- .../elasticsearch/plugins/InstallPluginCommand.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java b/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java index 4afe6b57e7e..3db532b84c8 100644 --- a/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java +++ b/core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java @@ -197,7 +197,7 @@ class InstallPluginCommand extends Command { version); } terminal.println("-> Downloading " + pluginId + " from elastic"); - return downloadZipAndChecksum(url, tmpDir); + return downloadZipAndChecksum(terminal, url, tmpDir); } // now try as maven coordinates, a valid URL would only have a colon and slash @@ -206,16 +206,17 @@ class InstallPluginCommand extends Command { String mavenUrl = String.format(Locale.ROOT, "https://repo1.maven.org/maven2/%1$s/%2$s/%3$s/%2$s-%3$s.zip", coordinates[0].replace(".", "/") /* groupId */, coordinates[1] /* artifactId */, coordinates[2] /* version */); terminal.println("-> Downloading " + pluginId + " from maven central"); - return downloadZipAndChecksum(mavenUrl, tmpDir); + return downloadZipAndChecksum(terminal, mavenUrl, tmpDir); } // fall back to plain old URL terminal.println("-> Downloading " + URLDecoder.decode(pluginId, "UTF-8")); - return downloadZip(pluginId, tmpDir); + return downloadZip(terminal, pluginId, tmpDir); } /** Downloads a zip from the url, into a temp file under the given temp dir. */ - private Path downloadZip(String urlString, Path tmpDir) throws IOException { + private Path downloadZip(Terminal terminal, String urlString, Path tmpDir) throws IOException { + terminal.println(VERBOSE, "Retrieving zip from " + urlString); URL url = new URL(urlString); Path zip = Files.createTempFile(tmpDir, null, ".zip"); try (InputStream in = url.openStream()) { @@ -226,8 +227,8 @@ class InstallPluginCommand extends Command { } /** Downloads a zip from the url, as well as a SHA1 checksum, and checks the checksum. */ - private Path downloadZipAndChecksum(String urlString, Path tmpDir) throws Exception { - Path zip = downloadZip(urlString, tmpDir); + private Path downloadZipAndChecksum(Terminal terminal, String urlString, Path tmpDir) throws Exception { + Path zip = downloadZip(terminal, urlString, tmpDir); URL checksumUrl = new URL(urlString + ".sha1"); final String expectedChecksum;