diff options
Diffstat (limited to 'platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java')
-rwxr-xr-x[-rw-r--r--] | platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java index 83858cc4fb40..f1206ef190f1 100644..100755 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.updateSettings.impl; +import com.google.common.net.HttpHeaders; import com.intellij.diagnostic.IdeErrorsDialog; import com.intellij.ide.IdeBundle; import com.intellij.ide.plugins.*; @@ -774,10 +775,31 @@ public final class UpdateChecker { String platform = PlatformUtils.getPlatformPrefix(); File tempFile = FileUtil.createTempFile(platform, "patch", true); + LOG.info(String.format("[Patch] Download %s to %s", fileName, tempFile.getAbsolutePath())); OutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile)); try { - URLConnection connection = HttpConfigurable.getInstance().openConnection(new URL(new URL(getPatchesUrl()), fileName).toString()); + String requestUrl = new URL(new URL(getPatchesUrl()), fileName).toString(); + URLConnection connection; + + int followCount = 2; + while(true) { + connection = HttpConfigurable.getInstance().openConnection(requestUrl); + + if (connection instanceof HttpURLConnection) { + HttpURLConnection hcnx = (HttpURLConnection)connection; + int code = hcnx.getResponseCode(); + if (code >= 301 && code <= 307 && --followCount >= 0) { + String loc = hcnx.getHeaderField(HttpHeaders.LOCATION); + if (loc != null) { + requestUrl = loc; + continue; + } + } + } + break; + } + try { InputStream in = UrlConnectionUtil.getConnectionInputStreamWithException(connection, i); try { @@ -819,6 +841,7 @@ public final class UpdateChecker { File patchFile = new File(FileUtil.getTempDirectory(), patchFileName); FileUtil.copy(tempFile, patchFile); FileUtil.delete(tempFile); + LOG.info(String.format("[Patch] moved to %s", patchFile.getAbsolutePath())); } public static Set<String> getDisabledToUpdatePlugins() { |