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 ea3561fff091..7ae2704d4156 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java @@ -613,13 +613,13 @@ public final class UpdateChecker { OutputStream out = null; String platform = PlatformUtils.getPlatformPrefix(); - String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase(); - File patchFile = new File(FileUtil.getTempDirectory(), patchFileName); + + File tempFile = FileUtil.createTempFile(platform, "patch", true); try { connection = new URL(new URL(getPatchesUrl()), fileName).openConnection(); in = UrlConnectionUtil.getConnectionInputStreamWithException(connection, i); - out = new BufferedOutputStream(new FileOutputStream(patchFile)); + out = new BufferedOutputStream(new FileOutputStream(tempFile)); i.setIndeterminate(false); @@ -636,23 +636,16 @@ public final class UpdateChecker { i.setText2((read / 1024) + "/" + (total / 1024) + " KB"); } } - catch (IOException e) { - patchFile.delete(); - throw e; - } - catch (ProcessCanceledException e) { - patchFile.delete(); - throw e; - } - catch (Throwable e) { - patchFile.delete(); - throw new RuntimeException(e); - } finally { if (out != null) out.close(); if (in != null) in.close(); if (connection instanceof HttpURLConnection) ((HttpURLConnection)connection).disconnect(); } + + String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase(); + File patchFile = new File(FileUtil.getTempDirectory(), patchFileName); + FileUtil.copy(tempFile, patchFile); + FileUtil.delete(tempFile); } public static Set getDisabledToUpdatePlugins() {