[platform] better diagnostics for corrupted patch files (IDEA-247985)
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Thu, 13 Aug 2020 17:16:32 +0000 (19:16 +0200)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Thu, 13 Aug 2020 17:16:32 +0000 (17:16 +0000)
GitOrigin-RevId: be0f30e29af50b5ecc7b7be56371c442539562d6

platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInstaller.kt

index 7e7c766e5326e4650365a36def288ca867401f9d..2b45327d327076fabbde3a8c8e1ea34594abe62f 100644 (file)
@@ -23,6 +23,7 @@ import java.io.IOException
 import java.net.URL
 import java.nio.file.Files
 import java.nio.file.Paths
+import java.util.zip.ZipException
 import java.util.zip.ZipFile
 import javax.swing.JComponent
 import javax.swing.UIManager
@@ -61,11 +62,16 @@ internal object UpdateInstaller {
         }
       }
       HttpRequests.request(url).gzip(false).saveToFile(patchFile, partIndicator)
-      ZipFile(patchFile).use {
-        if (it.getEntry(PATCH_FILE_NAME) == null || it.getEntry(UPDATER_ENTRY) == null) {
-          throw IOException("Corrupted patch file: ${patchFile.name}")
+      try {
+        ZipFile(patchFile).use {
+          if (it.getEntry(PATCH_FILE_NAME) == null || it.getEntry(UPDATER_ENTRY) == null) {
+            throw IOException("Corrupted patch file: ${patchFile.name}")
+          }
         }
       }
+      catch (e: ZipException) {
+        throw IOException("Corrupted patch file: ${patchFile.name}", e)
+      }
       files += patchFile
     }